Python 使用子流程方法使用selenium网格分发测试(普通网格或使用jenkins)

Python 使用子流程方法使用selenium网格分发测试(普通网格或使用jenkins),python,selenium,selenium-grid2,parallel-testing,Python,Selenium,Selenium Grid2,Parallel Testing,我想在本地机器和远程机器之间分发测试。我有两个测试,并想运行它们并排更快的执行。 一个在本地计算机上,另一个在远程计算机上。我已经在本地计算机上设置了集线器和一个节点,并且在远程计算机上注册了另一个节点 以下是保存在同一目录中的三个代码文件: TestOnChrome.py from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities fr

我想在本地机器和远程机器之间分发测试。我有两个测试,并想运行它们并排更快的执行。 一个在本地计算机上,另一个在远程计算机上。我已经在本地计算机上设置了集线器和一个节点,并且在远程计算机上注册了另一个节点

以下是保存在同一目录中的三个代码文件:

TestOnChrome.py

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support.ui import WebDriverWait
import time, unittest


class OnFirefox(unittest.TestCase):

    def setUp(self) :
        self.driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',desired_capabilities=DesiredCapabilities.CHROME)


    def test_Google_Search_FF(self):
        driver = self.driver
        driver.get("http://www.google.com")
        inputElement = driver.find_element_by_name("q")
        inputElement.send_keys("Cheese!")
        inputElement.submit()



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


if __name__ == "__main__":
    unittest.main()
TestOnChromeTwo.py

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support.ui import WebDriverWait
import time, unittest


class OnFirefox(unittest.TestCase):

    def setUp(self) :
        self.driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',desired_capabilities=DesiredCapabilities.CHROME)


    def test_Google_Search_FF(self):
        driver = self.driver
        driver.get("http://www.google.com")
        inputElement = driver.find_element_by_name("q")
        inputElement.send_keys("Cheese!")
        inputElement.submit()



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


if __name__ == "__main__":
    unittest.main()
这是我的跑步者

from subprocess import Popen
import glob
tests = glob.glob('test*.py')
processes = []
for test in tests:
    processes.append(Popen('python %s' % test, shell=True))
for process in processes:
    process.wait()

如果我运行runner.py,它会自动分发测试吗?使用我注册的节点?或者我需要做其他事情?

每当您的代码从grid hub请求浏览器时,grid hub将在其注册的网格节点中搜索与您请求的功能匹配的免费浏览器实例。您无需为此执行任何操作,只需在此处执行时请求浏览器
self.driver=webdriver.Remote(command_executor=)http://localhost:4444/wd/hub“,desired_capabilities=DesiredCapabilities.CHROME)

每当您的代码从网格中心请求浏览器时,grid hub将在其注册的网格节点中搜索与您请求的功能匹配的免费浏览器实例。您无需为此执行任何操作,只需在此处执行时请求浏览器
self.driver=webdriver.Remote(command_executor=)http://localhost:4444/wd/hub,desired_capabilities=DesiredCapabilities.CHROME)

非常感谢。这意味着我使用了正确的方法?非常感谢。这意味着我使用了正确的方法?