I'm using Xpath and having trouble pulling out what information I need from this HTML info to click this button:
[@id='domain-members']/div[@id='app']/div[@id='frameworkModule']/div[@id='header'][1]/nav[@class='navbar navbar-default navbar-fixed-top navbar-primary flex background']/div[@id='nav2']/ul[@class='flex no-padding height-50 list-style-none']/li[@class='dropdown dropdown-accordion nav-hover sysf-resources-module flex-1 flex']/span/a[@class='icon flex-1 flex justify-content-center align-items-center']
my code is:
folder = driver.find_element_by_xpath("//span[@title='______']")
folder.click()
any help or resources to point me towards where I can better find the info I want would be a great help!
cruisepandey
29.5k6 gold badges23 silver badges43 bronze badges
-
1Can you share the actual HTML ? the one that you've shared looks like a xpath itselfcruisepandey– cruisepandey2021年09月04日 13:22:31 +00:00Commented Sep 4, 2021 at 13:22
-
@cruisepandey heres a snip:ibb.co/wp2b2SK Its a dropdown menu and i need to select All FilesSSerb1989– SSerb19892021年09月04日 13:44:27 +00:00Commented Sep 4, 2021 at 13:44
1 Answer 1
This HTML is not built using Select and options tag, so one can not use Select class from Selenium.
Instead try to click directly :-
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@href='#resources']"))).click()
time.sleep(5)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "All Files"))).click()
Imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
answered Sep 4, 2021 at 14:01
cruisepandey
29.5k6 gold badges23 silver badges43 bronze badges
Sign up to request clarification or add additional context in comments.
11 Comments
SSerb1989
Thank you! I have an error message now Traceback (most recent call last): File "C:/Users/Sserb/PycharmProjects/WeSnare/main.py", line 33, in <module> WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//ul[@class='dropdown-menu']"))).click() File "C:\Users\Sserb\PycharmProjects\WeSnare\venv\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:
cruisepandey
Is page url public ?
SSerb1989
Its not, unfortunately. Is there a specific thing i can look for for you in the HTML?
cruisepandey
When you manually hover on this drop down, what is the HTML code, also please give me in text format. This is the way to share in text format :- Press F12 in Chrome -> go to element section -> then right click on the element you want to share the outer HTML - > select copy and then outer HTML
SSerb1989
<a href="#resources" class="icon flex-1 flex justify-content-center align-items-center" title="Files" data-toggle="dropdown"><i class="fas fa-briefcase fa-fw"></i></a>
|
default