小编Deb*_*anB的帖子

管理员禁用加载解压缩的扩展名

当我运行我的webdriver脚本时,我收到一个确认对话框,其中包含以下消息:

加载扩展时出错

无法从'C:\ Users\username\AppData\Local\Temp\scoped_dir6312_32763\internal'加载扩展程序.管理员禁用加载解压缩的扩展名.

你想重试吗?

是的

单击"是"可以运行测试.

我不知道为什么我提示这个对话框,

我已经尝试了下面提到的解决方法,但它们都没有工作:

  1. 用最新版本替换了chrome驱动程序.
  2. 在我的脚本中添加了以下代码:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("no-sandbox");
    options.addArguments("disable-extensions");
    driver = new ChromeDriver(options);
    
    Run Code Online (Sandbox Code Playgroud)

以下是我的测试方法:

public void Login() throws IOException{
    test = extent.startTest("Login");
    signInPage = new SignInPage(driver);
    signInPage.enterMailId();   
    String screenShotPath = GetScreenShot.capture(driver, "enterMailId");
    test.log(LogStatus.PASS, "Email id is entered successfully: " + test.addScreenCapture(screenShotPath));
    signInPage.enterpwd();
    //test.log(LogStatus.INFO, "Password is entered successfully");
    screenShotPath = GetScreenShot.capture(driver, "enterpwd");
    test.log(LogStatus.PASS, "Password is entered successfully: " + test.addScreenCapture(screenShotPath));
    signInPage.clickOnLogin();
    test.log(LogStatus.PASS, "User logged in successfully");
}
Run Code Online (Sandbox Code Playgroud)

以下是调用浏览器的方法:

private  void initChromeBrowser(){
    System.setProperty("webdriver.chrome.driver", …
Run Code Online (Sandbox Code Playgroud)

java selenium google-chrome selenium-chromedriver chrome-automation-extension

16
推荐指数
4
解决办法
4万
查看次数

元素MyElement在点(x,y)处不可点击...其他元素将收到点击

我正在尝试使用基于硒的Katalon Studio进行一些测试.在我的一个测试中,我必须在textarea内写.问题是我收到以下错误:

...Element MyElement is not clickable at point (x, y)... Other element would receive the click...
Run Code Online (Sandbox Code Playgroud)

事实上,我的元素位于其他可能隐藏它的diva中但是如何让click事件命中我的textarea?

java selenium webdriver selenium-webdriver katalon-studio

16
推荐指数
1
解决办法
6757
查看次数

java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap 尝试使用 Chromedriver 和 Maven 执行测试时出错

我是硒测试的新手,目前正在使用 Maven 观看一些 YouTube 视频。

今天我尝试了一些代码并且工作正常,但是当访问一个商店页面并尝试搜索产品时,它给我“访问被拒绝”消息所以我尝试了几种打开 chrome 而不是 chromedriver 的方法。

但我放弃了,愿意尝试另一个网页。但现在 chromedriver 无法打开(给出错误消息)。operadriver、geckodriver等将在启动后立即关闭。

我收到此错误:

java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap.of(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)'
Run Code Online (Sandbox Code Playgroud)

我尝试在很多地方查找,但大多数人说它是番石榴版本,我不使用番石榴,即使我尝试将其添加到依赖项中......

我的代码是这样的:

public class TestYoutubeClass {
    WebDriver driver;
    @Before
    public void runDriver(){
        WebDriver driver = new ChromeDriver();
        driver.get("http://www.kabum.com.br");
Run Code Online (Sandbox Code Playgroud)

我尝试从头开始,但没有任何效果。我正在使用 IntelliJ,pom.xml我添加了:junit; selenium-javawebdrivermanager

非常感谢每一个帮助。

java selenium nosuchmethoderror maven selenium-webdriver

16
推荐指数
4
解决办法
6万
查看次数

如何解决ElementNotInteractableException:在Selenium webdriver中看不到元素?

在这里,我有我的代码的图像和我的错误的图像.任何人都可以帮我解决这个问题吗?

在此输入图像描述

在此输入图像描述

java selenium webdriver selenium-webdriver webdriverwait

15
推荐指数
2
解决办法
3万
查看次数

selenium.common.exceptions.SessionNotCreatedException:消息:无法通过Selenium找到与Firefox 46匹配的一组功能

我必须在这里找到一些不匹配的版本,因为我无法使用Python启动Selenium来启动Firefox Web浏览器.我使用的是旧版本的Firefox,因为这里的其他人拥有相同的旧版本的Python,对于他们来说,旧版本的Firefox效果最好.

码:

from selenium import webdriver
from selenium import common
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver=webdriver.Firefox(capabilities=DesiredCapabilities.FIREFOX)
Run Code Online (Sandbox Code Playgroud)

错误:

Traceback (most recent call last):
  File "scrapeCommunitySelenium.py", line 13, in <module>
    driver=webdriver.Firefox(capabilities=DesiredCapabilities.FIREFOX)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 158, in __init__
    keep_alive=True)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters) …
Run Code Online (Sandbox Code Playgroud)

python firefox selenium selenium-webdriver geckodriver

15
推荐指数
3
解决办法
4万
查看次数

selenium.common.exceptions.WebDriverException:消息:无效的会话 id 使用 Selenium 与 ChromeDriver 和 Chrome 通过 Python

我正在使用 Selenium 编写一些代码,并且有一次我向不同的网站发出了 7 个请求。对于第一个,这很好用。但是,对于其他人,我收到会话 ID 错误。我认为我的浏览器配置正确,因为我确实从第一个网站获得了结果。我试图在请求之间放置一个 WebDriverWait,但无济于事。我认为这些网站可能会阻止我的请求。有谁知道如何解决这个问题?

如果这是愚蠢的事情或者我做错了什么,我很抱歉,我很新^^

提前致谢!

Traceback (most recent call last):
  File "/home/cena/PycharmProjects/Frikandelbroodje/main.py", line 56, in <module>
    dirk_price = get_price(dirk_url, dirk_classname)
  File "/home/cena/PycharmProjects/Frikandelbroodje/main.py", line 44, in get_price
    browser.get(url)
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid session id
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Linux 4.15.0-50-generic x86_64)
Run Code Online (Sandbox Code Playgroud)

python selenium google-chrome webdriver selenium-chromedriver

15
推荐指数
2
解决办法
3万
查看次数

Selenium ChromeDriver 给出“InitializeSandbox() 在进程 GPU 进程中使用多个线程调用”错误

我正在尝试使用 selenium chromedriver 打开一个网站。我已经添加了一些我在其他类似问题中看到的论点,但它没有解决问题。我基本上有这个代码:

 String baseUrl = "https://somesite.com";
 System.setProperty("webdriver.chrome.driver", "/usr/bin/google-chrome");
 ChromeDriverService service = ChromeDriverService.createDefaultService();
 ChromeOptions options = new ChromeOptions();
 options.addArguments("--start-maximized");
 options.addArguments("--disable-infobars");
 options.addArguments("--disable-gpu");
 options.addArguments("--disable-software-rasterizer");
 options.addArguments("no-sandbox");
 options.addArguments("headless");
 options.addArguments("--enable-native-gpu-memory-buffers");

 driver = new ChromeDriver(service, options);
 driver.get(baseUrl);
Run Code Online (Sandbox Code Playgroud)

当我运行上面的代码时,chrome 打开但页面没有改变。它还给出了这个输出:

[61263:61263:0903/005049.885829:ERROR:sandbox_linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.
Run Code Online (Sandbox Code Playgroud)

为什么会发生这种情况?

注意:我的操作系统是ubuntu 20.04。

java ubuntu selenium selenium-chromedriver selenium-webdriver

15
推荐指数
1
解决办法
3万
查看次数

TypeError: WebDriver.__init__() 在 Selenium Python 中使用 firefox_options 作为参数时出现意外的关键字参数 'firefox_options' 错误

我正在尝试创建一个从网站下载文件的脚本,为此我想更改下载文件路径。当我尝试使用 Firefox 选项执行此操作时,出现以下错误:

TypeError: WebDriver.__init__() got an unexpected keyword argument 'firefox_options'
Run Code Online (Sandbox Code Playgroud)

代码:

from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.keys import Keys
import time

options = Options()

options.add_argument("download.default_directory=C:\\Music")
browser = webdriver.Firefox(firefox_options=options, executable_path=r'C:\\selenium\\geckodriver.exe')
browser.get('https://duckduckgo.com/')
Run Code Online (Sandbox Code Playgroud)

python firefox selenium selenium-webdriver geckodriver

15
推荐指数
1
解决办法
3万
查看次数

TypeError: __init__() 使用带有公司 pac 文件的 Python Selenium ChromeDriver 时出现意外的关键字参数“service”错误

我已经为这个问题苦苦挣扎了一段时间,但现在我又回到了这个问题上。我正在尝试使用 selenium 使用 pac 文件从公司代理后面的 URL 中抓取数据。我正在使用 Chromedriver,我的浏览器在其配置中使用 pac 文件。

我一直在尝试使用所需的功能,但文档很糟糕或者我没有掌握一些东西。最初,我尝试使用 beautifulsoup 进行网页抓取,除了我现在需要的数据是 javascript 格式的之外,我一直在使用它,而无法使用 bs4 读取该数据。

下面是我的代码:

import pandas as pd
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

desired_capabilities = webdriver.DesiredCapabilities.CHROME.copy()

PAC_PROXY = {
    'proxyAutoconfigUrl': 'http://proxy-pac/proxy.pac',
}
proxy = Proxy()
proxy.proxy_autoconfig_url = PAC_PROXY['proxyAutoconfigUrl']

desired_capabilities = {}
proxy.add_to_capabilities(desired_capabilities)
URL = "https://mor.nlm.nih.gov/RxClass/search?query=ALIMENTARY%20TRACT%20AND%20METABOLISM%7CATC1-4&searchBy=class&sourceIds=a&drugSources=atc1-4%7Catc%2Cepc%7Cdailymed%2Cmeshpa%7Cmesh%2Cdisease%7Cmedrt%2Cchem%7Cdailymed%2Cmoa%7Cdailymed%2Cpe%7Cdailymed%2Cpk%7Cmedrt%2Ctc%7Cfmtsme%2Cva%7Cva%2Cdispos%7Csnomedct%2Cstruct%7Csnomedct%2Cschedule%7Crxnorm"

service …
Run Code Online (Sandbox Code Playgroud)

python selenium google-chrome selenium-chromedriver selenium-webdriver

15
推荐指数
2
解决办法
9万
查看次数

WebDriverException:消息:服务 geckodriver 意外退出。状态代码为:在 FreeBSD 监狱中使用 Selenium Geckodriver Firefox 时出现 64 错误

对于一些测试,我设置了一个普通的新 TrueNAS 12.3 FreeBSD Jail 并启动它,然后安装python3firefoxgeckodriverpip使用以下命令:

pkg install python3 firefox geckodriver py38-pip
pip install --upgrade pip
setenv CRYPTOGRAPHY_DONT_BUILD_RUST 1
pip install cryptography==3.4.7
pip install selenium
Run Code Online (Sandbox Code Playgroud)

之后,当我想在 Python 代码中将 Selenium 与 Firefox 一起使用时,它不起作用:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
Run Code Online (Sandbox Code Playgroud)

带来

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    self.service.start()
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 98, …
Run Code Online (Sandbox Code Playgroud)

python selenium freebsd geckodriver selenium4

15
推荐指数
1
解决办法
3万
查看次数