Wednesday, July 26, 2017

Scenario: Access calendar using Selenium Webdriver


Generally Calendar elements have common attribute values(no unique values to consider) even if there are more than one in a web page, So it makes these elements too complex to access and work on them.

So here we use siblings in the xpath. Means we go to the previou or next sibling of this item and create xpath for that item. Once we are able to access that element, write sibling to the xpath to access calendar element.

Testing website: https://www.goibibo.com

code:
<a href="/accounting.html">yyy</a>
<h4>zzz</h4>



<h4>  could be accessed using below code:


"//div[@class='canvas- graph']//a[@href='/accounting.html'][i[@class='icon-usd']]/following-sibling::h4"

1 comment: