0

i am trying to click on element in chrome driver browser using python and selenium. when trying to click i get the element not visible exception. this is html code:

 <div class="mid-content"><ul><li><b><span>Private</span><span><!-- react-text: 715 --> (<!-- /react-text --><!-- react-text: 716 -->
3<!-- /react-text --><!-- react-text: 717 -->)
<!-- /react-text --></span></b></li><li><img alt="" src="../img/UserProfile/lock.svg" width="18" height="24"></li><li class="bottom-title">Request to View</li></ul></div>

this is how click by xpath:

browser.find_element_by_xpath('//*[@id="App-content"]/div/div[1]/div[2]/div[1]/div[3]/div/div/a/div/ul')

its not working. but if i click in chrome driver browser manually first and then run this line of code it's everything working fine. What's the trick?please help me to solve this problem.

3
  • You need to make focus on that webelement first Commented Aug 27, 2018 at 13:37
  • There are multiple elements within the html you have shared, which element are you trying to locate? Commented Aug 27, 2018 at 13:39
  • When you post HTML and/or code please take a minute to use a beautifier like jsbeautifier.org or your IDE to properly format everything. If you need help properly formatting it on the site, see the formatting help link in the sidebar of the question editor. It makes it a LOT easier to read which makes your question more likely to get answered. Thanks! Commented Aug 27, 2018 at 18:49

1 Answer 1

1

Find different examples below how you can locate ul element.

Get ul element by css selector:

browser.find_element_css_selector('#App-content .mid-content ul')

Get ul element that contains "Private" and "3" texts:

browser.find_element_by_xpath('//*[@id="App-content"]//ul[contains(.,"Private") and contains(.,"3")]')

Get ul element that contains li with "Request to View" text and has child img tag:

browser.find_element_by_xpath('//*[@id="App-content"]//ul[./li[.="Request to View"] and .//img]')
Sign up to request clarification or add additional context in comments.

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.