【发布时间】:2020-07-08 07:44:49
【问题描述】:
下面的 javascript(与 Selenium 中的 Java 混合)不会在每次运行时成功运行 xpath 命令。但是我的 Java 命令运行成功,这是我遇到问题的 xpath。 (换句话说,有时 xpath 命令会成功运行,而有时则不会)。我将 jdk 从 13 更改为 jdk8,但没有奏效。我不知道需要什么。
我是学习自动化测试的新手,我正在自学。
这是命令行:
driver.findElement(By.xpath("//button[@type='button' and @data-test-id='checkbox']")).click();
错误响应:
JavaScript error: , line 0: NotAllowedError: The play method is not
allowed by the user agent or the platform in the current context,
possibly because the user denied permission.
Exception in thread "main"
org.openqa.selenium.StaleElementReferenceException: The element
reference of <button class="c27KHO0_n b_0 M_0 i_0 I_T y_Z2uhb3X
A_6EqO r_P C_q cvhIH6_T ir3_1JO2M7 P_0" type="button"> is stale;
either the element is no longer attached to the DOM, it is not
in the current frame context, or the document has been refreshed
【问题讨论】:
-
oes not run xpath command successfully on every run你得到什么错误信息?
标签: javascript selenium testing xpath automation