- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在将 VPN Chrome 应用程序用于 python 应用程序。每当我启动 Chrome 实例并且 Chrome 在 VPN 插件准备就绪之前开始加载网站时,就会出现以下弹出窗口。一旦我点击取消按钮,VPN 插件通常就准备好了,我可以毫无问题地访问互联网。
我正在寻找一种使用 Selenium 单击“取消”按钮的方法。
到目前为止我已经尝试过:
将主页设置为 Chrome 设置 -> 不会出现弹出窗口,因为设置不是网站,经过短暂的 sleep 后,大多数时候我都可以继续进行,没有任何问题。每隔一段时间,弹出窗口仍然会出现。
使用webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()
每当我尝试此操作时,脚本都会卡住,直到我手动单击“取消”按钮,然后执行该操作。 driver.get(url)
和 driver.switch_to.alert()
谢谢!
编辑 1(将 Chrome 选项设置为不显示通知和信息栏并不能解决问题):
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import selenium.common.exceptions
options = Options()
options.headless = False
options.add_argument("user-data-dir=ChromeProfiles\Profile_{}".format(22))
options.add_argument("--profile-directory=profile_1")
options.add_argument("--disable-notifications")
options.add_argument("--disable-infobars")
driver = webdriver.Chrome(options=options, executable_path="chromedriver.exe")
如您所见,只要弹出窗口打开,命令就不会执行:
最佳答案
1) void Dismiss()//单击警报的“取消”按钮。
driver.switchTo().alert().dismiss();
2) void Accept()//单击警报的“确定”按钮。
driver.switchTo().alert().accept();
3) String getText()//捕获警报消息。
driver.switchTo().alert().getText();
4) void sendKeys(String stringToSend)//发送一些数据到警报框。
driver.switchTo().alert().sendKeys("Text");
您可以引用 Guru 99 中的所有内容
您还应该看看它是什么类型的警报,浏览器推送通知、浏览器警报等...
这些是我的 Chrome 选项,用于禁用通知、警报和推送通知
chrome.switches = --incognito;--disable-download-notification;--disable-infobars
还有另一种实现 chrome 选项的方法
ChromeOptions ops = new ChromeOptions();
ops.addArguments("--disable-notifications");
ops.addArguments("--disable-infobars");
System.setProperty("webdriver.chrome.driver", "./lib/chromedriver");
driver = new ChromeDriver(ops);
最后,这里是 chrome 驱动程序文档,可以为您提供进一步帮助。 ChromeDriver Docs
编辑:
driver.switchTo().activeElement();
driver.close()
或者你可以尝试
Driver.SwitchTo().frame("NameOfFrame");
Driver.findElement("enter path to cancel button").click();
Driver.SwitchTo().defaultContent();
希望这有帮助
关于python - Selenium Chromedriver - 单击取消 Chrome 身份验证弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55537531/
昨天我更新了我的旧 chromedriver(v2.0.204324.dyu) 并在 https://code.google.com/p/chromedriver/downloads/list 上传了
我在使用 Selenium WebDriver.chromedriver 获取 json 结果数据时遇到问题,服务器将响应 http 状态代码 429 太多请求。 但是当我直接使用 chrome 获取
所以我在 stack here 上看到了一个类似的问题,但它没有被接受的答案,也没有为我提供我需要的信息。 我正在尝试使用“chromedriver”,因为“selenium-webdriver”需要
嗨,在 headless centos 7 中,我正在尝试进行 headless selenium 测试。为此,我安装了 google-chrome、chromedriver 和 selenium p
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我的问题与这篇文章有关:session not created: This version of ChromeDriver only supports Chrome version 74 error
我们试图在 Jenkins 上添加一些 selenium 脚本,但每当我们发出命令时,我都会收到错误消息“Chromedriver.exe 已停止工作”。 我将 chromedriver 移动到另一个
我使用的是 Macbook Pro,并且使用 Selenium 2.46.0 for Java 和 Chromedriver。我只有一个main方法,如下: public static void ma
我正在尝试在 heroku 上设置 selenium。我一直在看Running ChromeDriver with Python selenium on Heroku寻求帮助。基于此,我安装了列出的
当我设置初始设置 Nightwatchjs(使用初学者教程)时,出现如下错误: 尝试启动 ChromeDriver 时出错:无法解析路径:“/node_modules/.bin/chromedrive
我在 Windows 7 上使用 Selenium Chromedriver 时遇到问题。为了显示该问题,我将其简化为一个简单的脚本来简单地启动《纽约时报》网站: from selenium impo
问题 我一直在使用 Selenium 编写 Python 脚本,它在本地运行良好(因为我已将 ChromeDriver 安装在正确的目录中,即 assets/chromedriver),但它无法在赫罗
WebDriver driver = new ChromeDriver(options); 显示构造函数 ChromeDriver(ChromeOptions) 未定义,为什么? 最佳答案 导入以下语
我安装了 nuget 包 - Selenium.WebDriver.ChromeDriver 2.46.0.. 当我发布(通过 dotnet publish .Net CLI 命令).csprojec
我想用 chromedriver 从 fanfiction.net 上抓取一些故事。 我尝试以下方法: from selenium import webdriver import time path
当我尝试运行 npm install chromedriver 我得到... ChromeDriver installation failed Error extracting archive: Er
只是一个简单的 Python 代码: from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_
使用 C# 在 selenium 中哪里可以找到 chromedriver.log。在哪里可以看到chromedriver的日志文件? ChromeOptions optn= new ChromeOp
我在 Linux 上使用 Node 5.10.0。运行脚本时出现一些问题,如下所示 [davea@mydevbox mydir]$ node SkyNet.js Validation Complete
我是一名优秀的程序员,十分优秀!