相关疑难解决方法(0)

尝试与Selenium并行自动化,但多个webdriver实例吓坏了

所以我正在尝试创建一个使用Selenium自动化WebDriver在网站上执行任务的java程序.目前,我正在使用它进行工作,以便自动执行烦人的任务,用户必须将文件上传到我们的数据库.我已经成功地制作了一个自动执行此程序的程序,并节省了数小时的手动工作.

现在我想让程序并行运行多个浏览器.我想这样做是为了加快我上传文件的速度,因为大部分时间都在等待页面加载.

我用一个更简单的程序版本对此进行了测试,并通过使用自己的WebDrivers打开了数十到数百个线程,设法将简单任务加速了2-10倍.

问题是,每当我运行超过1个 WebDriver时,整个事情有时会开始随机发生,而在其他时候根本不起作用.我尝试使用'PhantomJSDriver'和最新的'PhantomJS.exe',但有时它会起作用,而且大多数时候它什么都不做.与一个驱动程序运行完美运行的相同程序在并行运行时会发生故障.

我一直试图找到原因,为什么会发生这种情况以及解决这个问题的方法,但我还没有找到任何可以使用的确定方法.

如果可能的话,我如何与Selenium并行进行自动化网页浏览,如果没有,为了做到这一点,我应该在哪里寻找?

parallel-processing selenium webdriver phantomjs

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

如何同时运行多个Selenium Firefox浏览器?

尝试在使用Selenium的同一台机器上同时运行多个进程.会发生什么是这样的:

python my_selenium_process1.py &
python my_selenium_process2.py &
python my_selenium_process3.py &
Run Code Online (Sandbox Code Playgroud)

据我所知,这导致Selenium按顺序打开Firefox实例,这不是理想的行为.

附加说明:根据超级用户关于多个Firefox实例的这个问题,这样做的方法是使用--no-remoteFirefox 的启动标志.这似乎是一个很好的方法,但我不确定是否有更简单的方法,或者这是否是我正在寻找的.

编辑:除了加速特定测试用例之外,其目的是允许多个Selenium进程同时运行.

非常感谢!任何建议将不胜感激!

python concurrency firefox selenium process

8
推荐指数
1
解决办法
7058
查看次数

python selenium多个测试用例

我在python中有以下代码

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from unittestzero import Assert
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import ElementNotVisibleException
import unittest, time, re

class HomePageTest(unittest.TestCase):
    expected_title="  some title here "
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(30)
        self.base_url = "https://somewebsite.com"
        self.verificationErrors = []

    def test_home_page(self):
        driver=self.driver
        driver.get(self.base_url)
        print "test some things here"




    def test_whatever(self):
        print "test some more things here"

    def tearDown(self):
        self.driver.quit()


if __name__ == "__main__":
    unittest.main()
Run Code Online (Sandbox Code Playgroud)

我的问题是在函数test_home_page之后,firefox实例关闭并再次为下一个test_whatever函数打开.我怎么能这样做所有测试用例都是从同一个firefox实例执行的.

python testing firefox selenium

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