标签:art html form splay server download 判断 releases 客户端
driver下载完成解压后,分别拷贝IEDriverServer.exe,geckodriver.exe,chromedriver.exe至Python安装路径(如C:\Python27\)下即可
java -jar selenium-server-standalone-3.5.0.jar -role hub
java -jar selenium-server-standalone-3.5.0.jar -role node -port 5555 -hub http://localhost:4444/grid/register
同理我们另外启动两个 node(使用端口号分别为5556/5557):
java -jar selenium-server-standalone-3.5.0.jar -role node -port 5556 -hub http://localhost:4444/grid/register
java -jar selenium-server-standalone-3.5.0.jar -role node -port 5557 -hub http://localhost:4444/grid/register
cd /d D:\grid
start java -jar selenium-server-standalone-3.5.0.jar -role hub
start java -jar selenium-server-standalone-3.5.0.jar -role node -port 5555 -hub http://localhost:4444/grid/register
start java -jar selenium-server-standalone-3.5.0.jar -role node -port 5556 -hub http://localhost:4444/grid/register
start java -jar selenium-server-standalone-3.5.0.jar -role node -port 5557 -hub http://localhost:4444/grid/register
d:\grid>java -jar selenium-server-standalone-3.5.0.jar --help
Usage: <main class> [options]
Options:
--version, -version
Displays the version and exits.
Default: false
-browserTimeout
<Integer> in seconds : number of seconds a browser session is allowed to
hang while a WebDriver command is running (example: driver.get(url)). If the
timeout is reached while a WebDriver command is still processing, the session
will quit. Minimum value is 60. An unspecified, zero, or negative value means
wait indefinitely.
Default: 0
-debug
<Boolean> : enables LogLevel.FINE.
Default: false
-enablePassThrough
<Boolean>: Whether or not to use the experimental passthrough mode.
Defaults to true.
Default: true
-jettyThreads, -jettyMaxThreads
<Integer> : max number of threads for Jetty. An unspecified, zero, or
negative value means the Jetty default value (200) will be used.
-log
<String> filename : the filename to use for logging. If omitted, will log
to STDOUT
-port
<Integer> : the port number the server will use.
Default: 4444
-role
<String> options are [hub], [node], or [standalone].
Default: standalone
-timeout, -sessionTimeout
<Integer> in seconds : Specifies the timeout before the server
automatically kills a session that hasn‘t had any activity in the last X seconds. The
test slot will then be released for another test to use. This is typically
used to take care of client crashes. For grid hub/node roles, cleanUpCycle
must also be set.
Default: 1800
# coding:utf-8
from selenium.webdriver import Remote
import time
# 定义node_hub与浏览器对应关系
nodes = {
‘http://127.0.0.1:5555/wd/hub‘: ‘chrome‘,
‘http://127.0.0.1:5556/wd/hub‘: ‘internet explorer‘,
‘http://127.0.0.1:5557/wd/hub‘: ‘firefox‘
}
# 通过不同的浏览器执行测试脚本
for host, browser in nodes.items():
print(host, browser)
# 调用remote方法
driver = Remote(command_executor=host,
desired_capabilities={‘platform‘: ‘ANY‘, ‘browserName‘: browser, ‘version‘: ‘‘, ‘javascriptEnabled‘: True})
# 打开百度首页并搜索词语,最后判断搜索跳转页面标题是否含有搜索词
wd = ‘lovesoo‘
driver.get(‘https://www.baidu.com‘)
driver.find_element_by_id("kw").send_keys(wd)
driver.find_element_by_id("su").click()
time.sleep(1)
assert wd in driver.title, ‘{0} not in {1}‘.format(wd, driver.title.encode(‘utf-8‘))
driver.quit()
(‘http://127.0.0.1:5555/wd/hub‘, ‘chrome‘)
(‘http://127.0.0.1:5557/wd/hub‘, ‘firefox‘)
(‘http://127.0.0.1:5556/wd/hub‘, ‘internet explorer‘)
标签:art html form splay server download 判断 releases 客户端
原文地址:http://www.cnblogs.com/tester-l/p/7771444.html