在我现在的公司,我们有大约10个网站..这些都来自单个代码库。
每当我们改变“核心”中的某些内容时代码库,我们希望并行运行所有10个网站上的测试。它在云中更容易,但我们也希望能够在本地完成。
为此,我基本上启动了多个Selenium实例,所有实例都有自己的端口,并为每个实例设置不同的nightwatch launch_url
所以我创建了一个NodeJS脚本..这为每个站点创建了一个nightwatch.json,每个站点都有自己的launch_url和selenium端口..并且会根据自己的json配置文件生成守夜人10次。
但是我想知道这是不是正确的'做法。
Selenium Grid是否解决了这个问题?还用于本地测试?
谢谢!
答案 0 :(得分:2)
Selenium网格旨在能够处理多个并行会话。
您应该只有一个含有一个或多个硒节点的硒中心。
使用额外的参数-browser
例如
java -jar selenium_server.jar -Dwebdriver.chrome.driver=$CHROMEDRIVER -role node -hub http://localhost:4444/grid/register -maxSession 20 -browser browserName=chrome,maxInstances=10 -browser browserName=firefox,maxInstances=10"
(对于maxSession与maxInstances之间的差异,请检查此项:Selenium Grid: MaxSessions vs MaxInstances)
您可以将所有测试配置为使用相同的selenium hub实例。
答案 1 :(得分:1)
Selenium grid won't solve your problem. Because selenium grid runs the same test cases over different instances. Selenium grid is used to check whether these test cases are compatible with different browsers, version of browsers or different OS. Check Selenium grid: http://www.seleniumhq.org/docs/07_selenium_grid.jsp
And in your case, you want to run test cases for different url's, therefore there are 10 different test cases set.
You are doing it right, "So I made a NodeJS script.. That creates a nightwatch.json for every site, each holding its own launch_url and selenium port.. And spawns nightwatch 10 times referring to its own json config file."
You can run each test case set in parallel by setting test_workers. Example: "test_workers" : {"enabled" : true, "workers" : "auto"}. Check test_workers to run test case in parallel http://nightwatchjs.org/gettingstarted/#basic-settings
Correct me if I am wrong.
答案 2 :(得分:0)
如果你想要云解决方案,nightwatch在nightwatch.json文件中与browserstack或saucelabs配合得非常好
"selenium" : {
"start_process" : true,
"server_path" : "lib/selenium/selenium-server-standalone-2.53.0.jar",
"start_session" : true,
"log_path" : "log/",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "lib/drivers/chromedriver"
}
},
"test_settings" : {
"bstk" : {
"launch_url": "http://hub.browserstack.com",
"selenium_port" : 80,
"selenium_host" : "hub.browserstack.com",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"browserstack.user": "username",
"browserstack.key": "..."
}
},