如何使用Selenide

问题描述

如何检查硒化物中的页面网址?

例如,我应该检查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);

使用 junit4Selenide 导入:

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.WebDriverRunner;
import static org.junit.Assert.assertEquals;

经过测试。结果: enter image description here

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...