使用硒ide访问不同的服务器(网址) [英] accessing different servers (urls) using selenium ide

查看:132
本文介绍了使用硒ide访问不同的服务器(网址)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打一个服务器x的URL,点击一个提交按钮并跳转到服务器y的同一个URL,然后点击同一个提交按钮,这必须重复26次,因为我必须改变26服务器。



这一切我都要做selenium ide。我设法为1台服务器做到这一点,但只是想知道是否有一个聪明的方式来做26 26服务器,而不是记录26次。

我使用硒2.9。 0使用Firefox浏览器的IDE插件

 <?xml version =1.0encoding =UTF-8?> 
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Strict // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
< head profile =http://selenium-ide.openqa.org/profiles/test-case>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/>
< link rel =selenium.basehref =http:// server-x:9173 //>
< title>新测试< / title>
< / head>
< body>
< table cellpadding =1cellspacing =1border =1>
< thead>
< tr>< td rowspan =1colspan =3>新测试< / td>< / tr>
< / thead>< tbody>
< tr>
< td>打开< / 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 =1cellspacing =1border =1>
< thead>
< tr>< td rowspan =1colspan =3>新测试< / td>< / tr>
< / thead>< tbody>
< tr>
< td>打开< / 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>


解决方案

您可以将基本网址保留为http:// 。然后,您需要为所有服务器URL使用readCSV,while循环用于重复服务器数量。

请参阅[ http://bashamy.blogspot.co.uk/2016/01/selenium-ide-to-use-while-loop-and-read.html] a>获取更多信息。

编辑网址: http://bashamy.blogspot.com/2016/01/selenium-ide-to-use-while-loop-and-read.html

例如:下面的html代码从我的CSV输入文件打开5个不同的网址。

 <?xml version =1.0encoding =UTF-8?> 
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Strict // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
< head profile =http://selenium-ide.openqa.org/profiles/test-case>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/>
< link rel =selenium.basehref =http://onlineconversion.com//>
< title> 06 ReadCsv_n_Loop< / title>
< / head>
< body>
< table cellpadding =1cellspacing =1border =1>
< thead>
< tr>< td rowspan =1colspan =3> 06 ReadCsv_n_Loop< / td>< / tr>
< / thead>< tbody>
< tr>
< td> readCSV< / td>
< td> file:// C:\Users\extayx\Documents\Selenium IDE\07Input.csv< / td>
< td>< / td>
< / tr>
< tr>
< td>商店< / td>
< td> 1< / td>
< td>行< / td>
< / tr>
< tr>
< td>商店< / td>
< td> 1< / td>
< td> col< / td>
< / tr>
< tr>
< td>商店< / td>
< td> 6< / td>
< td> z< / td>
< / tr>
< tr>
< td> while< / td>
< td> $ {row}& lt; $ {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>打开< / 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


I've a requirement to hit a url of server x, click a submit button and jump to same url of server y and click the same submit button and this has to be repeated 26 times as I've to change on 26 servers.

All this I have to do selenium ide. I managed to do this for 1 server but just wondering if there is a smart way to do this for 26 servers rather recording 26 times.

I'm using selenium 2.9.0 IDE plugin with firefox browser

 <?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>

解决方案

You can keep base url as "http://". You then need to use readCSV for all server urls and while loop for repeating for number of servers.

Please refer [http://bashamy.blogspot.co.uk/2016/01/selenium-ide-to-use-while-loop-and-read.html] for more information.

Edit Url: http://bashamy.blogspot.com/2016/01/selenium-ide-to-use-while-loop-and-read.html

Eg: Below html code opens 5 different urls from my CSV input file.

<?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 IDE\07Input.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}&lt;${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>

My input CSV file has below information.

www.google.co.in
www.google.com
www.google.co.uk
www.news.google.co.in
www.seleniumhq.org

这篇关于使用硒ide访问不同的服务器(网址)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆