【问题标题】:How to get rid of cookies notification in chrome browser using Selenium Java如何使用 Selenium Java 摆脱 chrome 浏览器中的 cookie 通知
【发布时间】:2020-11-07 22:53:14
【问题描述】:

我想请你帮我解决这个问题。我想用 Selenium 打开 chrome 窗口,使用 Java 语言。接下来我想找到输入元素并在那里放一些文本。问题是,我无法摆脱 cookie 通知,因为窗口总是在我未登录谷歌帐户的情况下打开。如何打开已经登录到我的帐户的 chrome 窗口?或者我怎样才能摆脱 google cookie 通知?

非常感谢。

【问题讨论】:

    标签: java selenium selenium-chromedriver


    【解决方案1】:

    Cookie 通常显示为警报,因此这可能有效:

    WebDriverWait wait = new WebDriverWait(driver,15);//create WebDriverWait
        wait.until(ExpectedConditions.alertIsPresent());//Wait for the alert
        driver.switchTo().alert().accept();//accept the alert
    

    【讨论】:

    • 不工作:/仍然弹出带有 cookie 通知的窗口
    猜你喜欢
    • 2019-02-03
    • 2019-09-05
    • 2013-05-03
    • 1970-01-01
    • 1970-01-01
    • 2017-01-22
    • 2019-02-09
    • 2017-10-10
    • 1970-01-01
    相关资源
    最近更新 更多