【问题标题】:Launching of GC when Selenium basic program is run运行 Selenium 基本程序时启动 GC
【发布时间】:2020-03-13 07:52:13
【问题描述】:

我在 Eclipse 中运行以下代码,但我的 Google Chrome 没有启动。

配置如下:

  • 面向 Java 开发人员的 Eclipse IDE
  • 版本:2019-12 (4.14.0)
  • 已采用最新版本的 GC 驱动程序。

相同的代码和配置适用于另一台笔记本电脑,但不适用于我的笔记本电脑。已经重新安装了几次应用程序。 互联网上所有可用的库也已导入。

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();
    }
}

【问题讨论】:

    标签: java selenium selenium-webdriver automated-tests


    【解决方案1】:

    你说铬?你没用过

    FirefoxDriver driver = new FirefoxDriver();
    

    你应该

    WebDriver driver = new ChromeDriver();
    

    你应该下载chromedriver.exe

    希望对你有帮助

    如果没有,请截图“Java Build Path”

    【讨论】:

      【解决方案2】:

      提取C:\\Users\\WC-Parul\\Downloads\\geckodriver-v0.26.0-win64.zip并提供geckodriver.exe路径

      类似

      System.setProperty("webdriver.firefox.driver", "C:\\Users\\WC-Parul\\Downloads\\geckodriver.exe");
      FirefoxDriver driver = new FirefoxDriver();
      driver.get("https://www.google.com/");
      

      确保您下载的geckodriver版本正确

      如果您想在 Chrome 浏览器上运行代码,请根据您的 chrome 浏览器版本从 here 下载兼容的 chromedriver.exe 并使用以下代码:

      System.setProperty("webdriver.chrome.driver", "drive_path\chromedriver.exe");
      ChromeDriver driver = new ChromeDriver();
      driver.get("https://www.google.com/");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-11-16
        • 2018-09-10
        • 1970-01-01
        • 2023-01-20
        • 2021-01-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多