我正在 Eclipse 中运行以下代码,但我的 Google Chrome 没有启动。
配置是:
- Eclipse IDE for Java Developers
- Version: 2019-12 (4.14.0)
- Have taken latest versions for GC driver.
相同的代码和配置适用于另一台笔记本电脑,但不适用于我的笔记本电脑。已重新安装该应用程序多次。 互联网上可用的所有库也已导入。
package automationFramework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.*;
public class FirstTestCase {
public static WebDriver driver;
public static void main(String[] args) {
System.setProperty("webdriver.firefox.driver", "C:\\Users\\WC-Parul\\Downloads\\geckodriver-v0.26.0-win64.zip");
FirefoxDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");
// Launch the Online Store Website
// driver.get("http://www.shop.demoqa.com");
// Print a Log In message to the screen
System.out.println("Successfully opened the website www.Store.Demoqa.com");
// Close the driver
// driver.quit();
}
}
最佳答案
你说的是Chrome?你没有使用
FirefoxDriver driver = new FirefoxDriver();
你应该
WebDriver driver = new ChromeDriver();
您应该下载 chromedriver.exe
希望对你有帮助
如果没有,请截图“Java Build Path”
关于java - Selenium 基本程序运行时启动 GC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60666730/