使用 selenium ide 访问不同的服务器(url)
accessing different servers (urls) using selenium ide
我需要点击服务器 x 的 url,单击提交按钮并跳转到服务器 y 的相同 url,然后单击相同的提交按钮,这必须重复26 次,因为我必须在 26 台服务器上更改。
所有这些我都必须做 selenium ide。我设法为 1 台服务器执行此操作,但只是想知道是否有一种聪明的方法可以为 26 台服务器执行此操作而不是记录 26 次。
我在 firefox 浏览器中使用 selenium 2.9.0 IDE 插件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://server-x:9173/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>website/delivery/DeliveryMethodsRepository/</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=DeliveryMethodsRepository/</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=invalidateCaches</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>name=submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=DeliveryMethodsRepository/</td>
<td></td>
</tr>
</tbody></table>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>inventory/InventoryRepository/</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=InventoryRepository/</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=invalidateCaches</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>name=submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=InventoryRepository/</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
你的问题很混乱,所以我可能理解错了。
在不太可能的情况下,我做对了,你正在尝试为不同的网站执行相同的任务 26 次。听起来像是循环可以做的事情。
这是示例 Python 代码:
urls = ['http://foo.bar', 'http://otherfoo.otherbar',...]
for url in urls:
driver.get(url)
#your selenium code here
这是我必须自己做的事情,并且可以使用一组名为 selite 或 selblocks 的插件(尽管 selite 已经包含此插件的一个版本)
使用这些插件,您可以将 URL 列表保存为外部 json 文件,然后循环测试用例,您只需将 'Forjson' 命令调用文件在您希望循环开始的阶段,以及希望循环结束的 'Endforjson' 阶段。所有文档都在 link 中。希望对你有帮助。
您可以将基数 url 保留为 "http://"。然后,您需要对所有服务器 url 使用 readCSV,并使用 while 循环重复服务器数量。
更多信息请参考[http://bashamy.blogspot.co.uk/2016/01/selenium-ide-to-use-while-loop-and-read.html]。
编辑 Url:http://bashamy.blogspot.com/2016/01/selenium-ide-to-use-while-loop-and-read.html
例如:html 下面的代码从我的 CSV 输入文件中打开 5 个不同的 url。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://onlineconversion.com/" />
<title>06 ReadCsv_n_Loop</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">06 ReadCsv_n_Loop</td></tr>
</thead><tbody>
<tr>
<td>readCSV</td>
<td>file://C:\Users\extayx\Documents\Selenium IDEInput.csv</td>
<td></td>
</tr>
<tr>
<td>store</td>
<td>1</td>
<td>row</td>
</tr>
<tr>
<td>store</td>
<td>1</td>
<td>col</td>
</tr>
<tr>
<td>store</td>
<td>6</td>
<td>z</td>
</tr>
<tr>
<td>while</td>
<td>${row}<${z}</td>
<td></td>
</tr>
<tr>
<td>storeCellValue</td>
<td>ip</td>
<td>${row},${col}</td>
</tr>
<tr>
<td>echo</td>
<td>${ip}</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${ip}</td>
<td>${ip}</td>
</tr>
<tr>
<td>storeEval</td>
<td>storedVars['row'] = ${row}+1</td>
<td>x</td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
我输入的 CSV 文件包含以下信息。
www.google.co.in
www.google.com
www.google.co.uk
www.news.google.co.in
www.seleniumhq.org
我需要点击服务器 x 的 url,单击提交按钮并跳转到服务器 y 的相同 url,然后单击相同的提交按钮,这必须重复26 次,因为我必须在 26 台服务器上更改。
所有这些我都必须做 selenium ide。我设法为 1 台服务器执行此操作,但只是想知道是否有一种聪明的方法可以为 26 台服务器执行此操作而不是记录 26 次。
我在 firefox 浏览器中使用 selenium 2.9.0 IDE 插件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://server-x:9173/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>website/delivery/DeliveryMethodsRepository/</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=DeliveryMethodsRepository/</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=invalidateCaches</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>name=submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=DeliveryMethodsRepository/</td>
<td></td>
</tr>
</tbody></table>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>inventory/InventoryRepository/</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=InventoryRepository/</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=invalidateCaches</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>name=submit</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=InventoryRepository/</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
你的问题很混乱,所以我可能理解错了。 在不太可能的情况下,我做对了,你正在尝试为不同的网站执行相同的任务 26 次。听起来像是循环可以做的事情。 这是示例 Python 代码:
urls = ['http://foo.bar', 'http://otherfoo.otherbar',...]
for url in urls:
driver.get(url)
#your selenium code here
这是我必须自己做的事情,并且可以使用一组名为 selite 或 selblocks 的插件(尽管 selite 已经包含此插件的一个版本)
使用这些插件,您可以将 URL 列表保存为外部 json 文件,然后循环测试用例,您只需将 'Forjson' 命令调用文件在您希望循环开始的阶段,以及希望循环结束的 'Endforjson' 阶段。所有文档都在 link 中。希望对你有帮助。
您可以将基数 url 保留为 "http://"。然后,您需要对所有服务器 url 使用 readCSV,并使用 while 循环重复服务器数量。
更多信息请参考[http://bashamy.blogspot.co.uk/2016/01/selenium-ide-to-use-while-loop-and-read.html]。
编辑 Url:http://bashamy.blogspot.com/2016/01/selenium-ide-to-use-while-loop-and-read.html
例如:html 下面的代码从我的 CSV 输入文件中打开 5 个不同的 url。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://onlineconversion.com/" />
<title>06 ReadCsv_n_Loop</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">06 ReadCsv_n_Loop</td></tr>
</thead><tbody>
<tr>
<td>readCSV</td>
<td>file://C:\Users\extayx\Documents\Selenium IDEInput.csv</td>
<td></td>
</tr>
<tr>
<td>store</td>
<td>1</td>
<td>row</td>
</tr>
<tr>
<td>store</td>
<td>1</td>
<td>col</td>
</tr>
<tr>
<td>store</td>
<td>6</td>
<td>z</td>
</tr>
<tr>
<td>while</td>
<td>${row}<${z}</td>
<td></td>
</tr>
<tr>
<td>storeCellValue</td>
<td>ip</td>
<td>${row},${col}</td>
</tr>
<tr>
<td>echo</td>
<td>${ip}</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${ip}</td>
<td>${ip}</td>
</tr>
<tr>
<td>storeEval</td>
<td>storedVars['row'] = ${row}+1</td>
<td>x</td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
我输入的 CSV 文件包含以下信息。
www.google.co.in
www.google.com
www.google.co.uk
www.news.google.co.in
www.seleniumhq.org