Reputation: 209
Selenium IDE exported this for Java/Junit
driver.findElement(By.cssSelector(".x-btn-inner:contains('Yes')")) .click();
and it doesn't work because contains doesn't exist in CSS. So I want to pass by XPath
driver.findElement(By.xpath("//.x-btn-inner[contains(., 'Yes']")).click();
this code isn't working, what am I doing wrong?
<span id="button-1006-btnEl" data-ref="btnEl" role="presentation" unselectable="on" style="" class="x-btn-button x-btn-button-default-small x-btn-text x-btn-button-center "><span id="button-1006-btnIconEl" data-ref="btnIconEl" role="presentation" unselectable="on" class="x-btn-icon-el x-btn-icon-el-default-small " style=""></span><span id="button-1006-btnInnerEl" data-ref="btnInnerEl" unselectable="on" class="x-btn-inner x-btn-inner-default-small">Yes</span></span>
The id is dynamically generated so I can't make use of it.
Upvotes: 1
Views: 86
Reputation: 474191
You can just get it by text:
driver.findElement(By.xpath("//span[. = 'Yes']")).click();
Upvotes: 1