1

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!

2
  • 1
    Can you share the actual HTML ? the one that you've shared looks like a xpath itself Commented Sep 4, 2021 at 13:22
  • @cruisepandey heres a snip:ibb.co/wp2b2SK Its a dropdown menu and i need to select All Files Commented Sep 4, 2021 at 13:44

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

11 Comments

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:
Is page url public ?
Its not, unfortunately. Is there a specific thing i can look for for you in the HTML?
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
<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>
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.