I am trying to write script which needs to open two boxes on webpage and get proper email address. I believe i am not inheriting elements on webpage properly. Please view my code below:
try:
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "body > section > section > section > div.mapAndAttrs > p:nth-child(2)")))
xxx = driver.find_element_by_css_selector("#titletextonly").text
#Click on Reply button
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.reply-button.js-only"))).click()
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'body > section > section > header > div.reply-button-row > div > div.reply-info.js-only')))
#target email address
to = driver.find_element_by_css_selector("body > section > section > header > div.reply-button-row > div > div.reply-info.js-only > aside.reply-flap.js-captcha > ul > li.reply-email > p > a").text
except:
Here is sample page from which I need to extract email: https://newyork.craigslist.org/fct/cto/d/ridgefield-2003-bmw-x5-30-xdrive/7212695001.html
Email is located in "reply" button and then another "show email" button.
Any guidance is greatly appreciated.