TestNGとJava Seleniumを使用しない場合はすべていいです。 Java SeleniumでTestNGを使用すると、このエラーが発生します。TestNG Selenium Java - java.lang.IllegalStateException:webdriver.chrome.driverシステムプロパティによってドライバの実行可能ファイルへのパスを設定する必要があります。
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
ドライバに実行可能なパスを既に設定していますが、コンパイラはまだ文句を言います。なにか提案を?ありがとう。
package testSuite;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Driver;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
//import org.junit.Test;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class testNG
{
\t
\t @Test
\t public void login() throws IOException {
\t \t System.setProperty("WebDriver.Chrome.Driver", "C:\\Users\\Desktop\\chromedriver_win32\\chromedriver.exe");
\t \t WebDriver driver = null;
\t \t Properties prop = new Properties();
\t \t FileInputStream file = new FileInputStream("C:\\Users\\workspace\\Selenium\\src\\testSuite\\config.properties");
\t \t prop.load(file);
\t \t
\t \t System.out.println(prop.getProperty("username"));
\t \t
\t \t if(prop.getProperty("browser").equals("chrome")) {
\t \t \t System.out.println("OKOK");
\t \t \t driver = new ChromeDriver();
\t \t \t
\t \t }
\t \t driver.get(prop.getProperty("url"));
\t \t
\t }
}
これは私の性質は、私は問題を発見した
username = 56987
password = 1234
url = www.google.com
browser = chrome
私は今、チェックすることはできませんが、私の頭の上からそれはあなたが設定されていない方法ですドライバへのパス。なぜTestNGが機能しないのでしょうか? 'ChromeOptions'インスタンスを作成し、そのパスを設定し、そのインスタンスをドライバインスタンスに設定する必要があります。コンストラクタの引数として、またはセッタを介して覚えていません。 – SantiBailors