超时异常,即使元素已被单击
timeout Exception even when element is already clicked
我正在尝试单击一个按钮登录,但即使在单击按钮后我也遇到超时异常。
我已经验证了代码并确认我使用了正确的定位器。
描述:CAP 演示
导航到 GitHub 网站,使用
搜索功能并转到回购主页
演员:
- 演员:WEB
段:
- 段:1
动作:
- 描述:导航至 GitHub 主页
动作:org.getopentest.selenium.NavigateTo
参数:
url: http://192.168.200.98:8780/CAFPortal/#/login
- description: Enter Login id
action: org.getopentest.selenium.SendKeys
args:
locator: {xpath: "//*[@id='login']/app-root/app-caf-login/div/div/div[2]/form/div[1]/input"}
text: ksood
sendEnter: true
- description: Enter password
action: org.getopentest.selenium.SendKeys
args:
locator: {xpath: "//*[@id='login']/app-root/app-caf-login/div/div/div[2]/form/div[2]/input"}
text: Acs@2018
sendEnter: true
- description: Pause for 60 second
action: org.getopentest.selenium.ActionsPause
args:
durationMs: 60000
- description: Display a greeting dialog box in the browser
action: org.getopentest.selenium.ExecuteScript
args:
script:
var message = "Hello World!";
alert(message);
- description: Click on sign in
action: org.getopentest.selenium.Click
args:
locator: {xpath: "//*[@id='login']/app-root/app-caf-login/div/div/div[2]/form/div[3]/div/div/button"}
只希望最后一个测试用例通过
任何 SendKeys
操作都不需要 sendEnter: true
参数。当您传递 sendEnter: true
时,该操作将在将键发送到文本框元素后 "press" 输入键。所以基本上,在您展示的测试中,第一个操作将输入用户名,然后按回车键,因此尝试不使用密码登录,当然会失败。
另一个问题是您错误地使用了 ActionsPause
关键字(更多信息 here). If you want to introduce a delay in your test, you can use the $delay() API,但您很少需要使用 OpenTest 执行此操作,因为同步是 built-in,这意味着所有在 UI 元素上执行某些工作的测试操作都知道如何在执行工作之前等待该元素可用。
我正在尝试单击一个按钮登录,但即使在单击按钮后我也遇到超时异常。
我已经验证了代码并确认我使用了正确的定位器。
描述:CAP 演示 导航到 GitHub 网站,使用 搜索功能并转到回购主页 演员: - 演员:WEB 段: - 段:1 动作: - 描述:导航至 GitHub 主页 动作:org.getopentest.selenium.NavigateTo 参数: url: http://192.168.200.98:8780/CAFPortal/#/login
- description: Enter Login id
action: org.getopentest.selenium.SendKeys
args:
locator: {xpath: "//*[@id='login']/app-root/app-caf-login/div/div/div[2]/form/div[1]/input"}
text: ksood
sendEnter: true
- description: Enter password
action: org.getopentest.selenium.SendKeys
args:
locator: {xpath: "//*[@id='login']/app-root/app-caf-login/div/div/div[2]/form/div[2]/input"}
text: Acs@2018
sendEnter: true
- description: Pause for 60 second
action: org.getopentest.selenium.ActionsPause
args:
durationMs: 60000
- description: Display a greeting dialog box in the browser
action: org.getopentest.selenium.ExecuteScript
args:
script:
var message = "Hello World!";
alert(message);
- description: Click on sign in
action: org.getopentest.selenium.Click
args:
locator: {xpath: "//*[@id='login']/app-root/app-caf-login/div/div/div[2]/form/div[3]/div/div/button"}
只希望最后一个测试用例通过
任何 SendKeys
操作都不需要 sendEnter: true
参数。当您传递 sendEnter: true
时,该操作将在将键发送到文本框元素后 "press" 输入键。所以基本上,在您展示的测试中,第一个操作将输入用户名,然后按回车键,因此尝试不使用密码登录,当然会失败。
另一个问题是您错误地使用了 ActionsPause
关键字(更多信息 here). If you want to introduce a delay in your test, you can use the $delay() API,但您很少需要使用 OpenTest 执行此操作,因为同步是 built-in,这意味着所有在 UI 元素上执行某些工作的测试操作都知道如何在执行工作之前等待该元素可用。