0
このサイトのテスト:http://store.demoqa.com/Selenium 2にパラメータを持つメソッドを書き込む方法は?
私のテストでは、カートに商品を追加したり、カートから製品を取り外すことができます。
私はこのようになりますパラメータを指定しない方法を書いた:
public AllProductPage chooseProduct() {
//Click on product iPhone5
driver.findElement(By.className("wpsc_buy_button")).click();
//Expected: Product "iPhone5" has been opened
return new AllProductPage(driver);
}
を私はパラメータを持つメソッドを記述し、テストではなく、私が書いたコード内の製品を選択する必要があります。
@Test
public void verifyThatBeCanAddAndRemoveTheProductFromCart() throws InterruptedException {
ImplicitWait(driver);
HomePage onHomePage = new HomePage(driver);
System.out.println("Step 1");
AllProductPage onAllProductPage = onHomePage.clickOnAllProduct();
System.out.println("Step 2");
onAllProductPage.chooseProduct();
onAllProductPage.buttonGoToCheckout();
onAllProductPage.submitForm();
System.out.println("Step 3");
Assert.assertTrue(onAllProductPage.getMessage().contains("Oops, there is nothing in your cart."));
}
これは私のエラーです:org.openqa.selenium.NoSuchElementException:そのような要素がありません:要素を見つけることができません: ""メソッド ":" xpath "、" selector ":" // div [contains(@class、 [iPhone 5])]] // input [@ name = 'wpsc_ajax_action'] "} –
「iPHONE5」の代わりに「iPhone 5」を使用します。 xpath。関数に渡すテキストは、ページのように正確に一致する必要があります。 – Renato
これは今エラーです:org.openqa.selenium.ElementNotVisibleException:要素が表示されません –