-1

This is the page https://www.wunderground.com/weather/gb/london I want to click on history. This is what I get when I inspect the element History

None of the find element methods has worked, I always get invalid syntax on my script. How can I find the element and select it?.Thank you

1 Answers1

0
driver.find_element_by_xpath("//span[.='History']").click()

Would be able to get it.

If that doesn't try the following.

wait = WebDriverWait(driver, 10)
driver.get("https://www.wunderground.com/weather/gb/london")

elem=wait.until(EC.presence_of_element_located((By.XPATH,"//button[./i[.='close']]")))
driver.execute_script("arguments[0].click();", elem)

elem=wait.until(EC.presence_of_element_located((By.XPATH,"//a[./span[.='History']]")))
driver.execute_script("arguments[0].click();", elem)

Import

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC
Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32