javascript - Dealing with hidden elements -


i trying scrape website , problem is, cannot interact hidden elements present on website. code follows:

before clicking

li class="header-nav__item login header-item-is-hidden" data-toggle="dropdown" style="display:list-item"  <a class="header-nav__link" href="#login-panel" aria-controls="login-panel" aria-expanded="true" aria-haspopup="true"></a>  <script src="../../../scripts/login/login.js" type="text/javascript"></script> <script src="../../../scripts/login/2falogin.js" type="text/javascript"></script> <script src="../../../scripts/common/error-handing.js" type="text/javascript"></script> <div id="login_pnldowntime"></div> <script type="text/javascript"></script> li 

after clicking

li class="header-nav__item jp-login header-item-is-hidden is-active" data-toggle="dropdown" style="display:list-item"  <a class="header-nav__link" href="#login-panel" aria-controls="login-panel" aria-expanded="true" aria-haspopup="true"></a>  <script src="../../../scripts/login/login.js" type="text/javascript"></script> <script src="../../../scripts/login/2falogin.js" type="text/javascript"></script> <script src="../../../scripts/common/error-handing.js" type="text/javascript"></script> <div id="login_pnldowntime"></div> <script type="text/javascript"></script>  li 

my source code

driver = webdriver.firefox() driver.get("http://www.website.com/home.aspx") print driver.page_source ele = driver.find_element_by_xpath("//ul[@class = 'header-nav']/li[3]")  #this deon because list element here third element in list ele.click() 

here on clicking element, dropdown not become visible. also, ele.click() emulating behaviour of hovering on element, , not clicking element.

source code of element that'll drop down on click

div id="login_pnldowntime" /div div id="login-panel" class="js-header-panel header-nav__dropdown right" aria-hidden="true" /div ::before class="privilege-promo form-section" href="/en/enrol-now.aspx">/a div class="privilege-form form-section" fieldset class="frm frm--vertical" input id="login_hddninvalidemail" type="hidden" value="invalid email id" name="ctl00$login$hddninvalidemail"> /input input id="login_hddninvalidnumber" type="hidden" value="invalid number" name="ctl00$login$hddninvalidnumber"> /input input id="login_hddninvalidmobilenumber" type="hidden" value="invalid mobile number" name="ctl00$login$hddninvalidmobilenumber"> /input input id="login_hddnflashmessagedelay" type="hidden" value="10000" name="ctl00$login$hddnflashmessagedelay"> /input button id="login_btnsubmitlogin" class="btn btn-primary align-right" onclick="javascript:webform_dopostbackwithoptions(new webform_postbac…n$btnsubmitlogin", "", true, "loginpage", "", false, false))" value="continue" name="ctl00$login$btnsubmitlogin" type="submit"> /button 

how perform click on element?

one thing element not (becomes) visible (css: display:none) , other thing element removed dom ex. removechild() method javascript.

  • in first case it's still in dom though hidden, selenium webdriver should able find id or other attribute.
  • in second case can't (it's not in dom).

from before/after clicking html it's not clear element/what happens it. use developer tools inspect in real time , post screenshots/html in question?

update

i found no elements class='header-nav' header-nav__dropdown not header-nav. should aware of it! if want locate class starting header-nav use starts-with() function.

second, element div, not ul according xpath. div id="login-panel" class="js-header-panel header-nav__dropdown right" aria-hidden="true" /div can't located , clicked.

could paste in question real html ul , lis, class='header-nav' etc. ?

i cannot interact since says element isn't visible

seems me have not mastered web dev tools in browser. must able see unvisible elements in dev. tools inspector. see this , this posts how that.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -