问题
My tests are Failing while running the in the Safari browser pointed to Browserstack
cloud env.
Could anyone please advise on how to fix the problem here. When a button is clicked, system displays a Modal Overlay and the "Show results" button is displaying inside the Modal overlay
I have tried the test with xpath
and By.cssSelector()
way to grab the button, but still not good.
WebElement showResultButton = driverSafari.findElement(By.cssSelector("div.modal-content .app-modal-footer.modal-footer button"));
String showBtnText = driverSafari.findElement(By.cssSelector("div.modal-content .app-modal-footer.modal-footer button")).getText();
showResultButton.click();
// Also I have tried below to reach the button:
WebElement showResultButton = driverSafari.findElement(By.cssSelector(".modal-content>.app-modal-footer.modal-footer>button"));
//The xpath way is also not working:
WebElement showresultButton = driverSafari.findElement(By.xpath("//button[text()='Show results']"));
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds
*** Element info: {Using=css selector, value=.modal-content>.app-modal-footer.modal-footer>button}
<div class="modal-content">
<div class="app-modal-header modal-header"></div>
<div class="app-modal-body modal-body"></div>
<div class="app-modal-footer modal-footer">
<button type="button" class="primary-button btn btn-primary btn-block">Show results</button>
</div>
</div>
来源:https://stackoverflow.com/questions/58871378/safari-browser-is-not-identifying-the-button-based-on-cssselector-or-xpath