问题描述
如何检查硒化物中的页面网址?
例如,我应该检查url()是否为www.google.pl
谢谢
解决方法
您需要获得 browser address url
。这是通过 current url
获取 Selenide
的方法:
String currentUrl = WebDriverRunner.getWebDriver().getCurrentUrl();
使用 junit4
assertEquals()
方法的解决方案示例:
String url = "http://www.google.pl";
Selenide.open(url);
String currentUrl = WebDriverRunner.getWebDriver().getCurrentUrl();
assertEquals(url,currentUrl);
使用 junit4
和 Selenide
导入:
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.WebDriverRunner;
import static org.junit.Assert.assertEquals;