automation - 程序中出现假阴性
问题描述
我正在尝试在 selenium 中执行简单的程序,但在成功运行后,我也收到了假阴性错误,任何人都可以帮忙。它工作正常,如果 id 正确,它可以自动登录,但即使它工作方法登录显示失败
package TestNG;
//import java.util.concurrent.TimeUnit;//
import org.testng.annotations.*;import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.openqa.selenium.*;
public class DemoTestNG
{
@Test
public void login()
{
System.setProperty("webdriver.chrome.driver", "C:\\BrowserDriver\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.netflix.com/nz/login");
System.out.println(driver.getCurrentUrl());
driver.findElement(By.id("id_userLoginId"));
WebElement username=driver.findElement(By.id("id_userLoginId"));
driver.findElement(By.id("id_password"));
WebElement password=driver.findElement(By.id("id_password"));
//driver.findElement(By.id("submit-login"));
WebElement loginbutton= driver.findElement(By.xpath("//button[text()='Sign in']"));
username.sendKeys("anything");
password.sendKeys("anything");
loginbutton.click();
String expectedUrl="https://www.netflix.com/browse";
String actualUrl = driver.getCurrentUrl();
//https://githubmemory.com/repo/cbeust/testng/issues/2524
//System.out.println(actualUrl);
//System.out.println(expectedUrl);
if(actualUrl.equalsIgnoreCase(expectedUrl))
{
System.out.println("FAIL");
}
else
{
System.out.println("PASS");
}
Assert.assertEquals(actualUrl, expectedUrl, "successfully to move dashboard");
//System.out.println("successfully moved to dashboard");
driver.close();
}
}
解决方案
推荐阅读
- c++ - 模板Node类的c ++构造函数
- c# - 在 ASP.NET MVC 中对 Foreach 循环中的项目求和
- python - macOS 中的 pipenv 和 conda
- python-3.x - vs代码无法导入python包但终端可以导入
- javascript - `import`语句的路径可以包含多个`/`吗?
- python - 使用 ffmpeg 连接文件夹中的所有 .mp4 文件
- java - 如何在不添加更多窗格的情况下在 ImageView JavaFx 中对图像切换进行动画处理
- python - QProcess 无法从 Telethon 的异步函数中读取
- python - 我在 PySpark 数据框中有一列(字符串数组)。如何打破数组并为数组中的每个字符串项创建单独的行?
- python - 如何聚类标签(在多标签分类问题中)大多一起出现在一个类中