Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

xpath wrong using selenium

I am trying to get Fax number but they gave me nothing these is page link https://www.barreaunantes.fr/annuaire-des-avocats/stephanie-dreux/

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.select import Select

PATH="C:\Program Files (x86)\chromedriver.exe"
url='https://www.barreaunantes.fr/annuaire-des-avocats/stephanie-dreux/'
driver =webdriver.Chrome(PATH)
wait = WebDriverWait(driver, 20)
driver.get(url)

Fax = driver.find_element(By.XPATH, "//p//strong[contains(text(),'Fax : ')]").text
print(Fax)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You’re trying to locate strong tag but you need a p tag:

Fax = driver.find_element(By.XPATH, "//p[strong[contains(text(),'Fax : ')]]").text
print(Fax.strip('Fax : '))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading