【问题标题】:Asserts in selenium TestNG (The method assertEquals(String, String) is undefined for the type Assert)selenium TestNG 中的断言(方法 assertEquals(String, String) 未定义类型断言)
【发布时间】:2022-01-21 07:22:38
【问题描述】:

面临的错误:

FAILED: f
java.lang.Error: Unresolved compilation problem: 
    The method assertEquals(String, String) is undefined for the type Assert
package firstTestNGpackage;

import net.jodah.failsafe.internal.util.Assert;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Reporter;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class FIrstTestNGfile {
    public String baseUrl = "http://demo.guru99.com/test/newtours/";
    String driverPath = "/home/local/ZOHOCORP/bala-pt4540/chromedriver";
    public WebDriver driver ;
  @Test
  public void f() {
          System.setProperty("webdriver.chrome.driver", driverPath);
          driver = new ChromeDriver();
          driver.get(baseUrl);
          String expectedTitle = "Welcome: Mercury Tours";
          String actualTitle = driver.getTitle();
          Assert.assertEquals(actualTitle, expectedTitle);
          driver.close();
    
  }
}

【问题讨论】:

    标签: java selenium selenium-webdriver testng assert


    【解决方案1】:

    import net.jodah.failsafe.internal.util.Assert;

    您确定这是正确的导入吗?我假设您想改用import org.testng.Assert;,因为它具有字符串比较方法:https://www.javadoc.io/doc/org.testng/testng/6.8.17/org/testng/Assert.html#assertEquals(java.lang.String,%20java.lang.String)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-04
      • 1970-01-01
      • 2023-01-10
      • 2015-07-30
      相关资源
      最近更新 更多