私は、ページに正しいURLとタイトルがロードされているかどうかをチェックする方法を作成しようとしました。 私のコードは何回か、何度か倒れます。 これは私のエラーです:正しいURLとタイトルページを自動的に確認する
java.lang.AssertionError: Checking if http://store.demoqa.com/products-page/product-category/accessories/ contains: imacs
は、これは私のコードです:
public void showNavigationLinks() {
Actions action = new Actions(driver);
String[] submenu = {"Accessories", "iMacs", "iPads" , "iPhones" , "iPods" , "MacBook"};
for(int i=0; i < submenu.length; i++) {
WebElement productCategory = waitForElementToBeDisplayed(By.xpath("//a[contains(.,'Product Category')]"), 5000);
action = action.moveToElement(productCategory);
WebElement submenuItem = waitForElementToBeDisplayed(By.xpath("//a[contains(.,'" + submenu[i] + "')]"), 5000);
action.moveToElement(submenuItem).click().build().perform();
String currentUrl = driver.getCurrentUrl();
String title = driver.getTitle();
Assert.assertTrue("Checking if " + currentUrl + " contains: " + submenu[i].toLowerCase(),
currentUrl.contains(submenu[i].toLowerCase()));
Assert.assertTrue("Checking if title contains: " + submenu[i],
title.contains(submenu[i]));
System.out.println(title);
}
[リンクであること、ナビゲーションを確認する可能性のある重複正しいページにつながる](http://stackoverflow.com/questions/41960839/verify-that-navigation-links-are-leading-to-correct-page) – mrfreester
これが以前のものとどのように違うかを私が知ることは難しいあなたが尋ねた6つの質問?私は最近同じような質問が他の誰かによって提起されたのを見たと思います。重複を避けるためにいくつかの質問を削除してください。乾杯:) – mrfreester