标签: selenium-firefoxdriver

为什么Selenium Firefox驱动程序会在父进程溢出时认为我的模态没有显示:隐藏?

编辑:我认为已经存在一个问题:http://code.google.com/p/selenium/issues/detail?id = 5717

所以基本上我正在使用Firefox驱动程序和div id="page-content"导致我的selenium测试失败,并且引用的问题中列出了错误:"元素当前不可见,因此可能无法与之交互"但另一个是?我能够将问题追溯到这样一个事实,即该ID具有css样式,overflow: hidden这是一个错误,还是我做错了什么?

我使用的是Selenium WebDriver版本:2.33.0.0,Firefox版本:22

测试和网站的来源是:https://github.com/tonyeung/selenium-overflow-issue

如需快速参考:下面的HTML是我的测试页面.对于那些不熟悉角度的人,只要你点击添加或编辑,它所做的就是显示一个html片段作为模态,你可以在这里看到一个现场演示:http://plnkr.co/edit/LzHqxAz0f2GurbL9BGyu?p =预习

<!DOCTYPE html>
<html data-ng-app="myApp">
    <head lang="en">
        <meta charset="utf-8">
        <title>Selenium Test</title>  

        <!-- // DO NOT REMOVE OR CHANGE ORDER OF THE FOLLOWING // -->
        <!-- bootstrap default css (DO NOT REMOVE) -->
        <link rel="stylesheet" href="css/bootstrap.min.css?v=1">
        <link rel="stylesheet" href="css/bootstrap-responsive.min.css?v=1">
    </head>
    <body>
        <div data-ng-controller="MyCtrl">
            <span id="added" data-ng-show="added">Added</span>
            <span id="edited" data-ng-show="edited">Edited</span>

            <div id="page-content" style="overflow:hidden">
            <!--<div id="page-content">-->
                <div class="employees view"> …
Run Code Online (Sandbox Code Playgroud)

c# selenium-firefoxdriver angularjs selenium-webdriver

6
推荐指数
1
解决办法
2534
查看次数

Selenium-Phantomjs下载csv

我正在尝试使用PhantomJS从对话框下载(保存到磁盘)CSV文件.使用firefox配置文件,通过设置浏览器配置文件属性,这将非常简单.有任何建议如何在phantomjs中下载excel文件?

这是使用firefox驱动程序完成的方法:

profile = webdriver.firefox.firefox_profile.FirefoxProfile()
profile.set_preference("browser.download.folderList",2)
profile.set_preference("browser.download.dir",self.opts['output_dir'])
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', ('application/octet-stream,application/msexcel'))
Run Code Online (Sandbox Code Playgroud)

我正在使用Phantomjs驱动程序:

webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true','--local-storage-path=/tmp'])
Run Code Online (Sandbox Code Playgroud)

并寻找一种方法来设置属性,可以覆盖保存到磁盘并设置数据的MIME类型.目前没有设置属性,PhantomJS驱动程序,不下载该文件.

我已阅读有关避免对话框等的链接,但在这种情况下,需要它.

python export-to-csv phantomjs selenium-firefoxdriver selenium-webdriver

6
推荐指数
1
解决办法
2993
查看次数

在java中创建FirefoxDriver时出现java.lang.NoSuchMethodError

试图:

WebDriver driver=new FirefoxDriver();
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

java.lang.NoSuchMethodError: org.openqa.selenium.Proxy.extractFrom(Lorg/openqa/selenium/Capabilities;)Lorg/openqa/selenium/Proxy;
  at org.openqa.selenium.firefox.FirefoxDriver.dropCapabilities(FirefoxDriver.java:313)
  at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
  at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
  at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
  at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
Run Code Online (Sandbox Code Playgroud)

这个问题在ubuntu上的firefox更新到32.0版本之后就开始了,我试着安装28.0版但是仍然无法正常工作.

有任何想法吗?提前致谢

将驱动程序版本更改为2.39后像curiosu所说,一个新的错误显示:

 org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on       port 7055 after 45000 ms. Firefox console output:
pp-system-share:{2e1445b0-2682-11e1-bfc2-0800200c9a66} visible
1409862347400   DeferredSave.extensions.json    DEBUG   Save changes
1409862347400   DeferredSave.extensions.json    DEBUG   Save changes
1409862347405   addons.xpi  DEBUG   Updating database with changes to installed add-ons
1409862347405   addons.xpi-utils    DEBUG   Updating add-on states
1409862347406   addons.xpi-utils    DEBUG   Writing add-ons list
1409862347407   addons.xpi  DEBUG   Registering manifest for /usr/lib/firefox/browser/extensions/langpack-en-ZA@firefox.mozilla.org.xpi
1409862347408 …
Run Code Online (Sandbox Code Playgroud)

java selenium-firefoxdriver selenium-webdriver

6
推荐指数
2
解决办法
9628
查看次数

如何避免谷歌搜索将 selenium webdriver 检测为异常行为?

我尝试使用selenium webdriver在 google 中按图像进行一次搜索,因此我的用户不需要手动打开浏览器并将图像 url 粘贴到那里。但谷歌说

我们的系统检测到来自您的计算机网络的异常流量。此页面会检查是否真的是您发送请求,而不是机器人。

并提供验证码,有没有办法避免使用 selenium webdriver 被谷歌检测为自动化

这是我的代码:

@Before
public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://images.google.com/searchbyimage?image_url=";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void test2() throws Exception {
    driver.get(baseUrl + "http://somesite.com/somepicture.jpg");
    driver.findElement(By.linkText("sometext"));

    System.out.println("finish");

}

@After
public void tearDown() throws Exception {
    driver.quit();
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {
        fail(verificationErrorString);
    }
}
Run Code Online (Sandbox Code Playgroud)

java selenium captcha selenium-firefoxdriver selenium-webdriver

6
推荐指数
1
解决办法
9700
查看次数

使用Selenium Webdriver屏幕截图导出为PDF

有没有人知道是否可以使用Selenium Firefox WebDriver中的屏幕截图功能将HTML导出为PDF?我有一个网页,其中包含打印特定的CSS,我需要自动下载.据我所知,屏幕截图功能将页面截图作为图像,但我正在寻找一个可扩展的PDF文件,这对于打印很有用.

pdf selenium webdriver selenium-firefoxdriver selenium-webdriver

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

如何为firefox设置selenium python环境?

如何为Firefox设置selenium python环境?我正在使用Firefox 50,selenium 3,python 3.5,我尝试了很多二进制文件并在环境路径中复制geckodriver等.

python selenium automation selenium-firefoxdriver

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

Selenium 在 Firefox 中使用过多内存

我在 Firefox 中使用 selenium 来自动化 Instagram 上的一些任务。它基本上在用户配置文件和通知页面之间来回切换,并根据发现的内容执行任务。

它有一个无限循环,可确保任务继续进行。我每隔几步就有 sleep() 函数,但内存使用量不断增加。我在 Python 中有这样的东西:

while(True):
    expected_conditions()
    ...doTask()
    driver.back()
    expected_conditions()
    ...doAnotherTask()
    driver.forward()
    expected_conditions()
Run Code Online (Sandbox Code Playgroud)

我从不关闭驱动程序,因为这会大大减慢程序的速度,因为它有很多查询要处理。有没有办法在不关闭或退出驱动程序的情况下防止内存使用增加超时?

编辑:添加了明确的条件,但这也没有帮助。我正在使用 Firefox 的无头模式。

python firefox selenium selenium-firefoxdriver geckodriver

6
推荐指数
2
解决办法
9375
查看次数

在Python + Selenium + Firefox WebDriver上配置代理

我无法通过Selenium Firefox WebDriver使用代理连接。

使用此配置,将生成连接,但不是通过代理而是通过本地服务器生成连接。

关于此事和本文档存在两个问题但似乎没有一个问题可以解决python3的问题:

def selenium_connect():

    proxy = "178.20.231.218"
    proxy_port = 80
    url = "https://www.whatsmyip.org/"

    fp = webdriver.FirefoxProfile()
    # Direct = 0, Manual = 1, PAC = 2, AUTODETECT = 4, SYSTEM = 5
    fp.set_preference("network.proxy.type", 1)
    fp.set_preference("network.proxy.http",proxy)
    fp.set_preference("network.proxy.http_port",proxy_port)
    fp.update_preferences()
    driver = webdriver.Firefox(firefox_profile=fp)
    driver.get(url)
Run Code Online (Sandbox Code Playgroud)

我正在使用Firefox Webdriver版本52.0.2和Python 3.7,以及标准的Ubuntu 16.04 Docker环境。

selenium python-3.x selenium-firefoxdriver selenium-webdriver

6
推荐指数
1
解决办法
595
查看次数

我需要减少执行硒操作链的时间

我目前正在使用 Python3 的 selenium 中的动作链来执行元素上的点击。目前执行所需的两个动作链需要大约 0.6 秒,我需要它们在 < 0.1 秒内执行。

到目前为止,我一直在使用 pyautogui 并将 pyautogui.PAUSE 设置为 0。这使我能够在不到 0.05 秒的时间内完成两次点击,但因为它实际上正在移动鼠标,所以我无法在该庄园测试时使用计算机。我也无法使用 pyautogui 同时运行多个测试。在我的调试过程中,我得出的结论是瓶颈在于执行步骤。

如果我错得离谱,请纠正我,但根据我的理解,selenium 似乎应该比 pyautogui 更快,因为它只是跳过一个步骤并直接进入浏览器。因此,我认为硒可能会人为地减慢作用链。如果是这样,有人知道如何防止它这样做吗?

下面,我添加了我当前正在使用的代码。每次点击大约需要 0.3 秒。

action_1 = webdriver.common.action_chains.ActionChains(driver)
action_1.move_to_element_with_offset(e, offset[0], offset[1])
action_1.click()
action_1.perform()
Run Code Online (Sandbox Code Playgroud)

[更新]:我将动作链分成单独的动作,并发现以下内容:

  • 计算动作链需要 0.008-0.009 秒
  • 移动到第一次点击需要 0.25-0.27 秒
  • 单击第一个需要 0.013-0.014 秒
  • 移动到第二次单击需要 0.25-0.27 秒
  • 单击第二个需要 0.06-0.09 秒

python selenium python-3.x selenium-firefoxdriver selenium-webdriver

6
推荐指数
1
解决办法
1210
查看次数

Selenium Python(3.141.0、Geckodriver 0.30.0)无法打开 Firefox Webdriver:“无法加载您的 Firefox 配置文件,它可能丢失或无法访问。”

已修复:将 Ubuntu 21.04 升级到 21.10 时,firefox(之前使用 apt 安装)被删除并使用 snap 版本安装。逆向(卸载 snap 版本并使用 apt 重新安装)这解决了我的问题。

在 dist 升级后我必须将 Firefox 重置为默认浏览器后,我应该进行调查。


当尝试使用 Selenium for Python 创建 Firefox Webdriver 时,我收到以下消息: “您的 Firefox 配置文件无法加载,它可能丢失或无法访问。” 单击“确定”后,将出现以下堆栈跟踪:

>>> foo = webdriver.Firefox()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jonathan/.local/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py", line 170, in __init__
    RemoteWebDriver.__init__(
  File "/home/jonathan/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/jonathan/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/jonathan/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response) …
Run Code Online (Sandbox Code Playgroud)

python-3.x selenium-firefoxdriver

6
推荐指数
1
解决办法
3555
查看次数