0

After clicking the selected country I want to get the number of "Total Confirmed" from the top of the website

Website: https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6

Below is the code i have written:

poland = driver.find_element_by_xpath("//h5//span[contains(text(),'Poland')]")
poland.click()
AMC
  • 2,642
  • 7
  • 13
  • 35
Paulina G
  • 13
  • 1
  • Can you be more specific? What is the issue, exactly? Please see [ask], [help/on-topic]. – AMC Mar 30 '20 at 00:16

1 Answers1

0

To extract the number "1,862" clicking on Poland is not mandatory, instead you need to induce WebDriverWait for either visibility_of_element_located() or element_to_be_clickable() and you can use the following based Locator Strategy:

  • Using XPATH and ``:

    driver.get('https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6')
    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//h5//span[contains(text(),'Poland')]//preceding::span[2]/strong"))).text)
    
    • Console Output:

      1,862
      
  • Using XPATH and ``:

    driver.get('https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6')
    print(WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//h5//span[contains(text(),'Poland')]//preceding::span[2]/strong"))).text)
    
    • Console Output:

      1,862
      
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352