0

I am using Selenium IDE in Chrome.

I have trouble as it's Ext JS, so certain class names are generated. I also might be having trouble due to the class name "x-list-body"?

I want to click on "This person here yes", like this:

Click: //div[@class='x-list']//em[.='This person here yes']

Here is the HTML from the webpage, excuse the mess:

<div class="x-list-body">
<div id="ext-gen159" class="x-list-body-inner">
<dl>
<dt style="width:100%;text-align:left;">
<em unselectable="on" "="">Woot Moot Boot</em>
</dt>
<div class="x-clear">
</div>
</dl>
<dl>
<dt style="width:100%;text-align:left;">
<em unselectable="on" "="">This is sparta</em>
</dt>
<div class="x-clear"></div></dl>
<dl>
<dt style="width:100%;text-align:left;">
<em unselectable="on" "="">Henry Print</em>
</dt>
<div class="x-clear"></div>
</dl>
<dl>
<dt style="width:100%;text-align:left;">
<em unselectable="on" "="">Minsy Blowman</em>
</dt>
<div class="x-clear"></div>
</dl>
<dl class="">
<dt style="width:100%;text-align:left;">
<em unselectable="on" "="">This person here yes</em>
</dt>
<div class="x-clear"></div>
</dl>
<dl class="">
<dt style="width:100%;text-align:left;">
<em unselectable="on" "="">Another cool person</em>
</dt>
<div class="x-clear"></div>
</dl>
</div>
</div>

Please do not give me JavaScript code etc..., I am using the FireFox addon IDE.

Thank you!

Saurabh Gaur
  • 23,507
  • 10
  • 54
  • 73
k1308517
  • 213
  • 3
  • 12

2 Answers2

1
driver.findElement(By.xpath("//em[contains(text(),'This person here yes')]")).click();
SaiPawan
  • 1,189
  • 7
  • 20
  • How do I use that? This is what my IDE looks like, where do I put it? https://s32.postimg.org/ln088zfmd/image.jpg Looks like JS to me... – k1308517 Jun 28 '16 at 12:35
  • I did click: //em[contains(text(),'steve Steve deSilva Job London')] but sadly it just gets highlighted in red, same issue as before sorry. – k1308517 Jun 28 '16 at 12:37
  • what is happening if you are clicking on that element manually. – SaiPawan Jun 28 '16 at 12:42
  • When I use the website normally? I click it and it is highlighted, next I click an arrow. https://s31.postimg.org/qm15vv6pn/image.jpg – k1308517 Jun 28 '16 at 12:47
  • similarly we have done click and it is getting highlighted.Then try to click on arrow webelement. – SaiPawan Jun 28 '16 at 12:50
  • or try using clickandwait instead of click – SaiPawan Jun 28 '16 at 12:51
  • Your code does not make it highlight sorry. Clicking on the arrow works though as I tested that line of code. The problem is highlighting, it's an error it doesn't work. – k1308517 Jun 28 '16 at 12:51
  • I'm sorry it still didn't work when I tried clickAndWait, it fails like before. – k1308517 Jun 28 '16 at 12:59
1

Yes, class name is a problem. If you don't want an exact match, then change selector to match partial class name:

//div[contains(@class,'x-list')]//em[.='This person here yes']

Also since you are selecting a very particular text, you may not even need that div selector, unless another em on the page has exactly the same text. I.e. you may be able to use:

//em[.='This person here yes']
timbre timbre
  • 12,648
  • 10
  • 46
  • 77