So I am trying to scrape https://www.iob.in/Branch.aspx and want to go to different pages and was using selenium for it. It works well on wider screen but on taller screens, the atm/branch button comes above pages 6/7 and selenium cant figure them out or scroll to reach. Any way around it or how to fix it?
I tried starting in maximised mode or setting a fixed window size but ut doesn’t resolve the issue
options.add_argument("window-size=1900,900")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
driver = webdriver.Chrome(
options=options,
)
driver.get("https://www.iob.in/Branch.aspx")
blah = []
for page in range(2, 10):
try:
WebDriverWait(driver, 20).until(
EC.visibility_of_element_located(
(
By.XPATH,
f"//*[@id='ctl00_ContentPlaceHolder1_gv_Branch']/tbody/tr[22]/td/table/tbody/tr/td[{page}]/a",
)
)
).click()
2
Answers
Selenium does not click the element if it is not inside the page’s visible area.
You can use javascript to click the element, even it’s not in visible area, like:
if you just want that selenium adjust the height to page, you can use this: