Safari browser is not identifying the button based on cssSelector or xpath

≡放荡痞女 提交于 2020-01-25 09:03:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!