我正在尝试从我的办公室环境运行一个基本的selenium脚本,它具有代理和防火墙设置.该脚本运行正常,但在每次执行之前它都会弹出一个提示"管理员禁用解压缩扩展的加载".这意味着我必须手动点击它才能继续,这违背了自动化的目的.

我用谷歌搜索并堆栈溢出错误,看起来有一个需要禁用的chrome选项useAutomationExtension.我去了蟒蛇搜索正确的语法(环境:Python的2.7-win32的,运行Chrome司机2.30.477700(0057494ad8732195794a7b32078424f92a5fce41)),但找不到合适的镀铬开关/选项.
我也看了这个:铬/ Chrome会从谷歌开关:https://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_switches.cc 和CHROM开关彼得的名单:https://开头彼得.SH /实验/铬的命令行开关/
我模糊地试过chrome_options.add_argument(' - disable-useAutomationExtension'),但这也没有帮助.
所以,我需要你的指导和建议.请帮忙.
Code_part:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re, os
from selenium.webdriver.chrome.options import Options
class Sel(unittest.TestCase):
def setUp(self):
# self.driver = webdriver.Firefox()
# Clean existing file before starting
#############################################
dlpath = "C:\Users\Baba\blacksheep_tracker.xlsm"
if os.path.exists(dlpath):
os.remove(dlpath)
############################################
chrome_options = Options()
chrome_options.add_argument("--cipher-suite-blacklist=0x0039,0x0033")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument('--start-maximized')
chrome_options.add_argument('--disable-useAutomationExtension')
self.driver = webdriver.Chrome(chrome_options=chrome_options)
self.driver.implicitly_wait(30)
self.base_url …Run Code Online (Sandbox Code Playgroud) python selenium google-chrome selenium-chromedriver selenium-webdriver
当我尝试在java中运行我的selenium脚本时,我得到以下弹出框:
Failed to load extension from:
C:\Users\xyz\AppData\Local\Temp\scoped_dir20432_5430\internal. Loading of unpacked extensions is disabled by the administrator.
Run Code Online (Sandbox Code Playgroud)
我试过chromeoption arguments在其他页面中找到过.但似乎都没有效果.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
public class testClass {
public static String driverPath = "D:/Selenium/Chrome Driver latest/chromedriver.exe";
public static WebDriver driver;
public static void main(String args[]) {
System.setProperty("webdriver.chrome.driver", driverPath);
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("--js-flags=--expose-gc");
options.addArguments("--enable-precise-memory-info");
options.addArguments("--disable-popup-blocking");
options.addArguments("--disable-default-apps");
options.addArguments("--enable-automation");
options.addArguments("test-type=browser");
options.addArguments("disable-infobars");
options.addArguments("disable-extensions");
driver = new ChromeDriver(options);
driver.navigate().to("http://google.com");
driver.quit();
}
}
Run Code Online (Sandbox Code Playgroud)
我被迫手动处理该弹出窗口.我怎么摆脱它?