This is the code I have
<button type="button" id="B-New" data-sap-ui="B-New" title="Add New Order" role="button" aria-disabled="false" tabindex="0" class="sapUiBtn sapUiBtnNorm sapUiBtnS sapUiBtnStd">Add</button>
xpath
for this is "//*[@id='B-New']"
I am trying to click the button but unable to so.
I have used xpath, ID class name everything but it is unable to click. This is what I am using
driver.findElement(By.xpath("//*[@id='B-New']")).click()
Kindly help.
I have also used javascript
jse.executeScript("document.getElementById('B-New').click()");
but it also doesn't work.
You should try using WebDriverWait
to wait until element is visible and enable to click as below :-
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement el = wait.until(ExpectedConditions.elementToBeClickable(By.id("B-New")));
el.click();
Note :- If this element is inside any frame
, you need to switch that frame before finding and clicking the element using driver.switchTo().frame("frame name or id")
.
Hope it helps..:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.