-1

My end goal is to click a "download menu" button and in order to get to the button i need to click some optinons before hand. One of the options i am strugling with is this one:

this is what the html looks like when i do an inspect element on the option:

<li class=" "><a href="90" id="15">The Pub</a></li>

when i click on the option "The Pub" the list class becomes active and reveals a download menu button to a pdf which is what i want to click, like so:

<li class="active"><a href="90" id="15">The Pub</a></li>

this is what the selector looks like when i do a copy selector on chrome:

#\31 5

this is what the xpath looks like when i do a copy xpath on chrome:

//*[@id="15"]

i have tried the following and everytime webdriver can not find it:

browser.find_element_by_css_selector("#\31 5")

browser.find_element_by_css_selector(r"#\31 5")

browser.find_element_by_xpath("//*[@id=\"15\"]")

7
  • Please show more HTML code around the option, at least include the whole dropdown menu and its parent node Commented Jan 29, 2018 at 2:18
  • Is it possible to share URL of this web? I think it is not a simple controller. Commented Jan 29, 2018 at 2:43
  • At which stage are you exactly stuck to click <li class=" "><a href="90" id="15">The Pub</a></li> or <li class="active"><a href="90" id="15">The Pub</a></li> ? Commented Jan 29, 2018 at 8:54
  • Have you looked to see if there is an IFRAME surrounding these elements? Have you tried locating the element by link text "The Pub"? Commented Jan 29, 2018 at 19:06
  • @Buaban i cant share the endpoint as its an intranet site Commented Jan 30, 2018 at 16:19

2 Answers 2

0
browser.find_element_by_id('15').click()
Sign up to request clarification or add additional context in comments.

6 Comments

unfortunately did not work, got this error: WebDriverException: Message: unknown error: Element <a href="90" id="15">...</a> is not clickable at point (2058, 823). Other element would receive the click: <div class="restaurants-outter-wrap">...</div> i think i may need to make the list class active?
can you try: browser.find_element_by_xpath('//a[@id="15"]/..').click()
if you need to manually change it: stackoverflow.com/questions/39434821/…
firstly thanks for helping, i tried the xpath duggestion but got errors, also tried it with backspacing the quotes and removing the .. but still got this error Message: element not visible. i also tried changing the class to active but the content didnt appear even though the class got set to active
whats the parent to the <li> tag?
|
0
By.XPath(".//a[contains(.,'The Pub') and count(a[contains(.,'The Pub')]) = 0]");

Comments

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.