我想检查API响应,然后点击一个特定的按钮,这样按钮就存在了,不需要进行可见性检查,但API仍然在后台检查一些有效性。我的步骤定义是"
@And("^I click on Describe your Shipment button$")
public void i_click_on_describe_your_shipment_button() {
Button.safeClick(driver, destinationLocation.describeYourShipmentButton());}
我试过了
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
但一直没有效果。
唯一对我有用的东西。
Thread.sleep()
我不想使用。有什么建议吗?
不知道如何在Selenium中解决这个问题,但你可以摆脱Thread.sleep与 等待性.
例子来自他们的Github页面。
@Test
public void updatesCustomerStatus() {
// Publish an asynchronous message to a broker (e.g. RabbitMQ):
messageBroker.publishMessage(updateCustomerStatusMessage);
// Awaitility lets you wait until the asynchronous operation completes:
await().atMost(5, SECONDS).until(customerStatusIsUpdated());
...
}