在Selenium中:啓動一個網站後,我們如何檢查是否啓動了正確的頁面。Selenium:啓動一個網站後,我們如何檢查是否啓動了正確的頁面
例如: 如果我想啓動www.google.com
,運行代碼後我該如何檢查是否啓動了相同的頁面。
我用,
Assert.assertEquals("Correct web page",driver.findElement(By.Xpath("<xpath of one of the element in the page>")).isDisplayed());
運行程序後,我得到了以下錯誤:
Exception in thread "main" java.lang.AssertionError: expected:<Correct web page> but was:<true>
提供的URL作爲參數,並在頁面加載斷言之後的'司機。 getCUrrentUrl()'等於你最初提供的URL。 –