用于检查selenium webdriver中的url的断言命令

Min*_*Min 6 xpath junit4 selenium-webdriver

由于网页上的网址没有xpath和id,我该如何检查我的实际网址是否与预期的网址匹配?

我在下面提供了我的代码,但它没有用.

String Actualtext = driver.findElement(By.linkText("http://localhost:8080/imdb/homepage")).getText();
Assert.assertEquals(Actualtext, "http://localhost:8080/imdb/homepage" );
System.out.println("URL matching --> Part executed");
Run Code Online (Sandbox Code Playgroud)

nit*_*wda 18

您可以根据"当前网址"对其进行验证

String URL = driver.getCurrentUrl();
Assert.assertEquals(URL, "http://localhost:8080/imdb/homepage" );
Run Code Online (Sandbox Code Playgroud)