java - Selenium 无法获取http

标签 java selenium selenium-webdriver

我在 Eclipse 中尝试了以下代码。当我运行此代码时,firefox 将打开,但 driver.get("https://www.easybooking.lk/login ");不工作。请帮我解决这个错误

package login;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class easylogin {

    //public static void main(String[] args) {
        // TODO Auto-generated method stub
        public static void main(String[] args) throws InterruptedException {
            //Object webdriver;
            System.setProperty("webdriver.gecko.driver", "D:\\jjpppp\\geckodriver-v0.17.0-win64/geckodriver.exe");

            WebDriver driver = new FirefoxDriver();
            driver.manage().window().maximize();
            driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
            driver.get("https://www.easybooking.lk/login");  

我收到以下错误。我怎样才能解决这个问题?我添加了 Selenium 火狐驱动程序

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:872)
    at login.easylogin.main(easylogin.java:20)

最佳答案

根据错误消息,implicitlyWait 似乎存在一些问题。它似乎不起作用。只需注释此代码并检查一次即可

driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);

关于java - Selenium 无法获取http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47029756/

相关文章:

java - Spark 类型不匹配 : cannot convert from JavaRDD<Object> to JavaRDD<String>

java - 当 java 给出错误 "The system cannot find the file specified"时,我如何知道找不到哪个文件?

java - Java SWT GridLayout 可以从右到左布局小部件吗?

python - “Unable to find a matching set of capabilities”,使用 Selenium 和 Python 以及 Windows 10 上的当前 Firefox

java - 具有失败的配置:@BeforeClass setUp和失败的配置:@AfterClass tearDown java.lang.NullPointerException错误

java - 无法使用 Selenium WebDriver 和 Java 单击鼠标悬停链接

java - 滑动刷新后加载更多不起作用

java - 如何使用 Selenium RC for Eclipse Java 将文本输入到 tinymce 文本区域

java - Selenium 远程驱动程序错误转发新 session 找不到

Python selenium - 与主机、端口、用户名、密码的代理连接