自动化测试框架爱好者,非培训机构、非托、非盈利,纯个人!软件自动化测试交流 请加我QQ 459864689!更多自动化测试的信息请访问我的个人小站www.zhushangyuan.cn,专门研究selenium自动化测试框架的分享站点。

使用Selenium Server测试无线路由器Web管理页面

上一篇 / 下一篇  2013-04-18 17:12:37 / 个人分类:自动化测试

使用Selenium Server测试无线路由器Web管理页面

51Testing软件测试网#M;{2bWGF'p

f^&q4_o{0

最近在做WIFI吞吐率的测试,需要登录到无线路由器的Web管理页面对无线参数的频段和模式等进行更改。更改无线参数之后,再使用IxChariot等工具对WIFI吞吐率进行测试。项目组想把这个过程自动化起来,IxChariot工具自动化很容易实现,对无线参数的更改决定使用Selenium工具进行自动化更改。遇到的问题是,访问http://192.168.1.1时,无法解决登录问题,因为Selenium不支持Windows安全对话框(windows security dialog)!对话框上面的信息为:位于Mercury Wireless Router MW548R的服务器192.168.1.1 要求用户名和密码。警告:此服务器要求以不安全的方式发送您的用户名和密码(没有安全连接的基本认证)。51Testing软件测试网OD ^ H$\X8Yq4o

来自www.openqa.org的解决方式为:
How do I use Selenium to login to sites that require HTTP basic authentication (where the browser makes a modal dialog asking for credentials)?
Use a username and password in the URL, as described in RFC 1738:
Test Type 
open http://myusername:myuserpassword@myexample.com/blah/blah/blah 
Note that on Internet Explorer this won’t work, since Microsoft has disabled usernames/passwords in URLs in IE. However, you can add that functionality back in by modifying your registry, as described in the linked KB article. Set an “iexplore.exe” DWORD to 0 in HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE.
If you don’t want to modify the registry yourself, you can always just use Selenium Remote Control, which automatically sets that that registry key for you as of version 0.9.2.

Y,lQ[(b)L4D~1b0

除非注明,文章均为LoggingSelenium网站原创,欢迎转载!转载请注明本文地址,谢谢。本文地址:http://loggingselenium.com/?p=335 .非常感谢!51Testing软件测试网aZ-P[&v3s

中文解释如下:
可以把用户名和密码加到URL中进行解决,比如http://admin:admin@192.168.1.1这样就不会再需要登录,直接进去操作即可。对于IE,需要修改注册表,把下属内容复制到reg格式的文件双击执行即可。51Testing软件测试网&u'a;y x{n6et2Q9Y

Windows Registry Editor Version 5.0051Testing软件测试网qrD_@&Y#|

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE]
“iexplore.exe”=dword:00000000
下面给出相关的Selenium的源代码:51Testing软件测试网WGv:V/o


!P8a8rOB4F4M0
51Testing软件测试网U7? O m3ELv#_5|6u-Av
packagedw.junit;importorg.junit.*;importcom.thoughtworks.selenium.*; publicclassMercuryTestingextendsSeleneseTestBase{privatestaticSelenium selenium; 
	@BeforeClasspublicstaticvoidsetUpBeforeClass()throwsException{selenium=newDefaultSelenium("localhost",4444,"*iexplore","http://192.168.1.1");System.out.println("正在启动Selenium。。。");selenium.start();selenium.setTimeout(60*1000+"");selenium.windowMaximize();selenium.open("http://admin:admin@192.168.1.1/");} 
	@AfterClasspublicstaticvoidtearDownAfterClass()throwsException{if(selenium!=null){System.out.println("停止Selenium!");selenium.stop();}} 
	@Testpublicvoidtestaa(){// 点击左侧的无线参数导航链接selenium.click("//a[text()='无线参数']");// 切换模式selenium.select("//select[@name='mode']","label=11Mbps (802.11b)");}}

TAG:

 

评分:0

我来说两句

Open Toolbar