Alejandro Castillo
Alejandro Castillo

Reputation: 11

Can't get the propper Xpath to pass to Selenium with python

I'm stuck with a selenium scrape using jupyter. I'm trying to get the "download page data" from the bottom right corner of this page: https://polkadot.subscan.io/account?role=all&page=1

enter image description here

Also, here's the html code:

Download page data

I've tried copying the xpath and full xpath from the Google Chrome "inspect" tab, but it doesn't work.

Here's the code I used, but feel free to suggest anything else.

#Initiating Webdriver
s=Service('CHROMEDRIVER LOCATION')
op = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=s, options=op)

link = "https://polkadot.subscan.io/account?role=all&page=1"

driver.get(link)

Ingresar = driver.find_element(By.XPATH,"//*[@id='app']/main/div/div/div[5]/div/div[3]/div[1]/div/div")

Here's the error I get:

ElementClickInterceptedException: Message: element click intercepted: Element <div data-v-24af4670="" class="label align-items-center">...</div> is not clickable at point (125, 721). Other element would receive the click: <div data-v-c018c6b4="" class="banner">...</div>

Either fixing my code, or getting a new one that works with jupyer and selenium

Upvotes: 1

Views: 37

Answers (1)

AbiSaran
AbiSaran

Reputation: 2678

Try this code:

url = "https://polkadot.subscan.io/account?role=all&page=1"
driver.get(url)

driver.find_element(By.XPATH, ".//*[text()='I accept']").click()
time.sleep(5)
download_btn = driver.find_element(By.XPATH, ".//*[text()='Download page data']")
driver.execute_script("arguments[0].scrollIntoView(true);", download_btn)
download_btn.click()

Upvotes: 1

Related Questions