Я хотел бы нажать одну кнопку, так как сейчас я использую XPATH, но иногда страница меняется, и я должен обновить XPATH.
Я проверяю другой способ (найдите и щелкните изображение, например play.png, щелкните по тексту и т. Д. c.), Чтобы получить тот же результат.
После часть кода HTML:
<button class="btn btn-green false">PLAY</button>
РЕДАКТИРОВАТЬ:
Я пробовал с кодом
driver.findElement(By.xpath("//*[contains(text(),’PLAY’]")).click();
, но он идет в исключении
Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.xpath: //*[contains(text(),’PLAY’] (tried for 10 second(s) with 500 milliseconds interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:95)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)
at seleniumTest.TestSelenium.play(TestSelenium.java:300)
at seleniumTest.TestSelenium.open_url(TestSelenium.java:277)
at seleniumTest.TestSelenium.seleniumTest(TestSelenium.java:108)
at seleniumTest.TestSelenium.main(TestSelenium.java:85)
Caused by: org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //*[contains(text(),’PLAY’] because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//*[contains(text(),’PLAY’]' is not a valid XPath expression.