Skip to main content

Hi i am trying to locate element in selenium:

<button class="add-widget ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" title="Add widget" role="button" aria-disabled="false">**
    <span class="ui-button-icon-primary ui-icon ui-icon-plus"></span>
    <span class="ui-button-text"></span>
</button>

I tried to use this xpath selection:

driver.findElement(By.xpath("//button[contains(@class,'add-widget ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-state-hover')]/span[contains(@class,'ui-button-icon-primary')]")).click();

driver.findElement(By.xpath("//button[contains(@class,'add-widget ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-state-hover')]/span[contains(@class,'ui-button-icon-primary')]")).click();

But iit doesn't work and gives NoSuchElementExceptionNoSuchElementException. Could you give me an advice how to build xpath to this element?

Hi i am trying to locate element in selenium:

<button class="add-widget ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" title="Add widget" role="button" aria-disabled="false">**
<span class="ui-button-icon-primary ui-icon ui-icon-plus"></span>
<span class="ui-button-text"></span>
</button>

I tried to use this xpath selection:

driver.findElement(By.xpath("//button[contains(@class,'add-widget ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-state-hover')]/span[contains(@class,'ui-button-icon-primary')]")).click();

But i doesn't work and gives NoSuchElementException. Could you give me an advice how to build xpath to this element?

Hi i am trying to locate element in selenium:

<button class="add-widget ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" title="Add widget" role="button" aria-disabled="false">**
    <span class="ui-button-icon-primary ui-icon ui-icon-plus"></span>
    <span class="ui-button-text"></span>
</button>

I tried to use this xpath selection:

driver.findElement(By.xpath("//button[contains(@class,'add-widget ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-state-hover')]/span[contains(@class,'ui-button-icon-primary')]")).click();

But it doesn't work and gives NoSuchElementException. Could you give me an advice how to build xpath to this element?

Source Link
siutex
  • 52
  • 2
  • 10

Unable to locate element in Selenium Java

Hi i am trying to locate element in selenium:

<button class="add-widget ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" title="Add widget" role="button" aria-disabled="false">**
<span class="ui-button-icon-primary ui-icon ui-icon-plus"></span>
<span class="ui-button-text"></span>
</button>

I tried to use this xpath selection:

driver.findElement(By.xpath("//button[contains(@class,'add-widget ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-state-hover')]/span[contains(@class,'ui-button-icon-primary')]")).click();

But i doesn't work and gives NoSuchElementException. Could you give me an advice how to build xpath to this element?