Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99018

Xpath and className are not working even though path and name are correct

$
0
0

I want to click "Action" button and select the option "Update Reference data".
Actions buttonenter image description here

Here is my code

 Thread.sleep(30000);// To load the page
 driver.findElement(By.xpath("//*[@id=\"spend_mgmt_actions_menu\"]")).click();
 Thread.sleep(2000);
 driver.findElement(By.xpath("//*[id=\"upgradeRefData_button\"]")).click();

I also tried this, but got the same exception

WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"spend_mgmt_actions_button\"]")));
driver.findElement(By.className("button show-right-icon f-dropdown-facade actions-list-button plan-action-button")).click();
Thread.sleep(20000);

But when I run the code it gives:

No Such Element Exception unable to locate.....

Below is the HTML code copied from browser by selecting the element.

<button id="spend_mgmt_actions_button"
class="button show-right-icon f-dropdown-facade actions-list-button plan-action-button"
aria-hidden="false" aria-haspopup="true" data-dropdown="spend_mgmt_actions_menu" tabindex="0">
<span>Actions</span><span class="icon icon-right fa fa-caret-down"></span></button>


 <button id="upgradeRefData_button" class="list-item dd-item" aria-disabled="false"
 data-dropdown-item="" role="menuitem" tabindex="0" title=""><span>Update Reference Data</span>
 </button>

Viewing all articles
Browse latest Browse all 99018

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>