Monday, 15 April 2013

html - Selenium WebDriver - How to identify the element from custom drop-down. DIV, UL and LI -


I am trying to automate a custom drop-down field in which DV, UL, and LI I'm unable to use the Select Class or CSSSelector.

  & lt; Div id = "boundlist-1092" class = "x-boundlist x-boundlist-floating x-layer x-boundlist-default x-border-box x-boundlist-above" tabindex = "- 1" style = "true: automatic :; Left: 495px; top: 245px; height: auto; z-index: 29001; width: 150px; "& gt; & Lt; Div id = "boundlist-1092-listEl" class = "x-boundlist-list-ct x-unselectable" style = "overflow: auto; height: auto;" & Gt; & Lt; Ul class = "x-list-plain" & gt; & Lt; Li class = "x-boundlist-item" unselected = "on" role = "option" & gt; Single & lt; / Li & gt; & Lt; Li class = "x-boundlist-item" unselectable = "on" role = "option" & gt; Married filing jointly & lt; / Li & gt; & Lt; Li class = "x-boundlist-item" unselectable = "on" role = "options" & gt; Separated from married filing & lt; / Li & gt; & Lt; Li class = "x-boundlist-item" Incredible = "role =" option "& gt; Top of the house & lt; / Li & gt; & Lt; Li class = "x-boundlist-item" unselectable = "on" role = "options" & gt; Eligibility Widows (er) & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

However, the HTML code looks different when the element is visible

  & lt; Div id = "boundlist-1092" class = "x-boundlist x -bindlist-floating x-layer x-boundlight-default x-border-box x-byte-up-up" tabindex = "- 1" style = "right : Auto; left: 495px; top: 245px; height: auto; z-index: 29001; width: 150px; "& gt; & Lt; Div id = "boundlist-1092-listEl" class = "x-boundlist-list-ct x-unselectable" style = "overflow: auto; height: auto;" & Gt; & Lt; Ul class = "x-list-plain" & gt; & Lt; Li class = "x-boundlist-item x-boundlist-selected" unselectable = "but" role = "option" & gt; Single & lt; / Li & gt; & Lt; Li class = "x-boundlist-item" unselectable = "on" role = "option" & gt; Married filing jointly & lt; / Li & gt; & Lt; Li class = "x-boundlist-item" unselectable = "on" role = "options" & gt; Separated from married filing & lt; / Li & gt; & Lt; Li class = "x-boundlist-item" Incredible = "role =" option "& gt; Top of the house & lt; / Li & gt; & Lt; Li class = "x-boundlist-item" unselectable = "on" role = "options" & gt; Eligibility Widows (er) & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

If someone can help me, then it will be very helpful.

To detect the dropdown, you have an partial match Apply expression: // div [with begin (with @id, "boundlist-")]

Here we get a Are saying for the boundlist -

element with id attribute beginning with element .

To find inside dropdown elements, I use a text match:

  // div [initially (@id, "boundlist - ")] / Li [. = "Married filing jointly"]  

where . refers to the text of the current element.


No comments:

Post a Comment