1

This is the webpage -- link. I am going to crawl (In Persian). I have a problem when I am going to click on the next page button. The XPath is:

nextpage = '//*[@id="ctl00_ContentPlaceHolder1_ASPxSplitter1_CallbackPaneldgd_dgd_DXPagerBottom"]/a[1]/img'
page = driver.find_element_by_xpath(nextpage)
page.click()

After the page.click() I got the following error:

selenium.common.exceptions.ElementNotVisibleException: Message: element not visible

Some answers say there might be a duplicate XPath, but I could not find such a thing in the source of the webpage.

The complete code:

import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains


driver = webdriver.Chrome(executable_path='./chromedriver')
url = 'http://hmi.mrud.ir/sabaa/SABAA/Home/Default.aspx?strTownship=0101&g=false'
driver.get(url) 
time.sleep(10)   
nextpage = '//*[@id="ctl00_ContentPlaceHolder1_ASPxSplitter1_CallbackPaneldgd_dgd_DXPagerBottom"]/a[1]/img'
page = driver.find_element_by_xpath(nextpage)
page.click()

Thanks.

2 Answers 2

2

Use the following before clicking on the element:

driver.execute_script("arguments[0].scrollIntoView(true);", page)

This is scrolling to the element.

Hope it helps you!

Sign up to request clarification or add additional context in comments.

Comments

1

As per the Website if you want to click on the Next Page Button you have to induce WebDriverWait for the WebElement to be clickable following either of the code block as follows :

nextpage = WebDriverWait(driver, 10).until(EC.element_to_be_clickable(By.XPATH,"//div[@id='ctl00_ContentPlaceHolder1_ASPxSplitter1_CallbackPaneldgd_dgd_DXPagerBottom']/a[@class='dxp-lead dxp-button dxp-bi']/img[@class='dxWeb_pPrev_Aqua']"))
nextpage.click()

Or

nextpage = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_xpath("//div[@id='ctl00_ContentPlaceHolder1_ASPxSplitter1_CallbackPaneldgd_dgd_DXPagerBottom']/a[@class='dxp-lead dxp-button dxp-bi']/img[@class='dxWeb_pPrev_Aqua']"))
nextpage.click()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.