没有浏览器的硒测试 [英] Selenium testing without browser
问题描述
我使用Selenium RC进行测试.现在要执行负载测试,我想运行并行测试用例. 有什么方法可以在不打开浏览器的情况下运行它们?
I use Selenium RC for testing. Now to perform a load test, I want to run parallel test cases. Is there any way to run them without opening a browser?
推荐答案
要在Centos上进行设置(以root身份进行所有安装)
To set up on Centos (do all installation as root)
安装pip下载 https://bootstrap.pypa.io/get-pip.py
python get-pip.py
安装硒 如果您的系统上有pip,则可以简单地安装或升级Python绑定: pip install -U硒
Installing selenium If you have pip on your system, you can simply install or upgrade the Python bindings: pip install -U selenium
或者,您可以从PyPI下载源代码发行版(例如selenium-2.53.1.tar.gz),将其取消存档,然后运行:
Alternately, you can download the source distribution from PyPI (e.g. selenium-2.53.1.tar.gz), unarchive it, and run:
python setup.py install
安装程序:pyvirtualdisplay
install the program: pyvirtualdisplay
pip install pyvirtualdisplay
yum install Xvfb libXfont Xorg
然后修改脚本,以在**和**中添加粗体
Then modify your script to add the bold lines within ** and **
**from pyvirtualdisplay import Display**
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
class SeleniumDemo(unittest.TestCase):
def setUp(self):
**self.display = Display(visible=0, size=(800, 600))
self.display.start()**
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://www.soastastore.com/"
self.verificationErrors = []
self.accept_next_alert = True
def tearDown(self):`enter code here`
self.driver.quit()
***self.display.stop()***
self.assertEqual([], self.verificationErrors)
这篇关于没有浏览器的硒测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!