Created
June 22, 2018 15:04
-
-
Save NinaSalimi/6500b9981a41c345c0c10d5ac87ee6a7 to your computer and use it in GitHub Desktop.
How can I iterate through a list of items and extract a specific part using Selenium and Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium import webdriver | |
chrome_path=r"G:\My Drive\chrome_driver\chromedriver_win32\chromedriver.exe" | |
driver=webdriver.Chrome(chrome_path) | |
driver.get('https://meshb.nlm.nih.gov/treeView') | |
sidebar = driver.find_element_by_xpath("/html/body/div[2]/div") | |
i=1 | |
for i in range(16): # since I have 16 div(s) | |
sidebar.find_elements_by_xpath("/html/body/div[2]/div/div[i]") | |
element = driver.find_element_by_xpath("/html/body/div[2]/div").find_element_by_xpath("/html/body/div[2]/div/div[i]").find_element_by_xpath("//*[@class='ng-scope']/span") | |
element.click() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment