Reputation: 488
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.
Upvotes: 0
Views: 124
Reputation: 12255
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]')
Upvotes: 1