c# - How to count only elements displayed on WebPage. Selenium -
i have web page 2 tabs.
when count of elements on 1 tab gives me count both tabs not on 1 have clicked on.
so if want check element present of tab1 , not on tab2 not able getting same results on both tabs.
if (driver.findelements(by.xpath("//div[contains(text(), 'dummy text')]")).count != 0) { // failed test message ; }
on tab1 expecting count should 0 text not displayed , on tab2 count should 8 on both tabs count 8.
how can count of elements displayed on page , not in background?
i sure because of tabs on web page , selenium considering both tabs same web page content.
selenium return objects in dom not visible user.
i not believe there xpath or css selector allows select visible elements. can think of potential nasty xpath ensure no parent had display:none not know if work , sounds horrible , complex contemplate.
you need iterate through each returned element , check "displayed" returns false. tempted extend driver class have finddisplayedelements method wrap functionality you.
however approach expensive in terms of api calls if using remotewebdriver. alternative ensure parent object hidden, children inherit behaviour
Comments
Post a Comment