简体   繁体   English

java.lang.IllegalMonitorStateException (java selenium)

[英]java.lang.IllegalMonitorStateException (java selenium)

package main_files;

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

public class main_downloader {
    public static void main(String[] args) throws Exception {
        System.setProperty("webdriver.gecko.driver", "path\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.wait(1);
        driver.get("https://www.google.com/");
        driver.wait(5);
        driver.quit();
    }
}

for some reason when I try to run this code it gives me this Error出于某种原因,当我尝试运行此代码时,它给了我这个错误

1597445198205   geckodriver INFO    Listening on 127.0.0.1:7834
1597445198836   mozrunner::runner   INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\ahmed\\AppData\\Local\\Temp\\rust_mozprofileinTqzS"
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory.
console.error: SearchCache: "_readCacheFile: Error reading cache file:" (new Error("", "(unknown module)"))
1597445201342   Marionette  INFO    Listening on port 22663
1597445201445   Marionette  WARN    TLS certificate errors will be ignored for this session
Aug 15, 2020 1:46:41 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" java.lang.IllegalMonitorStateException
    at java.lang.Object.wait(Native Method)
    at main_files.main_downloader.main(main_downloader.java:10)

i've tried some solutions but nothing worked,?我已经尝试了一些解决方案,但没有任何效果,? could anyone help please.?有人可以帮忙吗? Thx.谢谢。

wait() function call must be called from Synchronized block to avoid this exception. wait() function 调用必须从同步块调用以避免此异常。 Do you want to sleep the main thread, if yes please use Thread.sleep() instead of wait() function call.是否要让主线程休眠,如果是,请使用 Thread.sleep() 而不是 wait() function 调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 超时时发生java.lang.IllegalMonitorStateException - java.lang.IllegalMonitorStateException on timeout 通知异常 java.lang.IllegalMonitorStateException Locks - Notify exception java.lang.IllegalMonitorStateException Locks notifyAll()方法上的java.lang.IllegalMonitorStateException - java.lang.IllegalMonitorStateException on notifyAll() method 线程“main”java.lang.IllegalMonitorStateException中的异常 - Exception in thread “main” java.lang.IllegalMonitorStateException 我的代码抛出java.lang.IllegalMonitorStateException - my code throws java.lang.IllegalMonitorStateException 导致java.lang.IllegalMonitorStateException的原因 - What causes an java.lang.IllegalMonitorStateException Producer Consumer的Java实现抛出java.lang.IllegalMonitorStateException - Java implementation of Producer Consumer throws java.lang.IllegalMonitorStateException Java reenrantlock 解锁抛出 java.lang.IllegalMonitorStateException - Java reenrantlock unlock throws java.lang.IllegalMonitorStateException 从同步块中调用wait时发生java.lang.IllegalMonitorStateException - java.lang.IllegalMonitorStateException whilst calling wait from synchronized block 餐饮哲学家的Monitor类中的java.lang.IllegalMonitorStateException - java.lang.IllegalMonitorStateException in Monitor class of dining philosophers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM