selenium 和webdriver_入门实践

上一篇 / 下一篇  2012-04-27 10:08:38 / 个人分类:Selenium

我们一直非常强调建立以底层为核心的分层自动化测试体系,虽然webui自动化在破页、美感方面不值得投入,但是由于目前大量业务逻辑在web ui,所以合适的web ui测试自动比率也是非常关键的。51Testing软件测试网ty4Lj/])KMoy

  watir设计理念和selenium有很大差异。watir便于测试工程师快速上手,对ie支持非常好;而selenium擅长浏览器兼容性。
.h g4c1g6r:C R0
51Testing软件测试网.sJqOi,h1}c6K

   参考:51Testing软件测试网/Nz-gs2c"Q

http://code.google.com/p/meimei/wiki/SeleniumUsage

C}fo*M)iw0

http://blog.csdn.net/shendl/archive/2009/03/08/3969750.aspx51Testing软件测试网v/DZ6R5_ B j ~

http://blog.csdn.net/shendl/archive/2009/03/08/3969750.aspx51Testing软件测试网l)f,E X2?$w0imf

http://www.ibm.com/developerworks/cn/java/j-lo-selenium/51Testing软件测试网;{iCgC/cG~P

http://www.onlymarshall.com/tag/selenium/

-|l5g;_5[-~"r3W(M0

扩展http://xace.javaeye.com/blog/579722

^/\F:UT:s-q'}3ms0

 

;f_+s@9~:_8X#\0

http://code.google.com/p/selenium/downloads/list下载selenium-server-standalone-2.0a2.jarselenium-server-standalone-2.0a2.jar51Testing软件测试网gtT0M4FMD

 51Testing软件测试网m/o6w;_6a4X Ie

Webdriver是对selenium的一个封装,更加友好。Selenium2.0已经把webdriver合并进去。

8W(M)f}:HS0

 执行http://code.google.com/p/selenium/wiki/GettingStarted代码出错。

hP%\.L-A"y;nE0

1       webdriver错误:

2`j;D1Z!Y0

Exception in thread "main"org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed.51Testing软件测试网 }4hf ?*WXV/@

 解决办法:指定firefox执行文件入系统属性。51Testing软件测试网aH ]0T P0i

    System.setProperty("webdriver.firefox.bin","D:/Program Files/Mozilla Firefox/firefox.exe");

6u@d+YsA'|6EJ0

       WebDriver driver =newFirefoxDriver();

_*dC|fR\:ok(^0

       
}(BRhc&M+A0
51Testing软件测试网k&^#]V0}9|Bk`p

2       解决selenium错误:

ci u~X;nNN0

 51Testing软件测试网%J"i%i _r xSx:J4A

下载样例代码http://www.ibm.com/developerworks/cn/java/j-lo-selenium/51Testing软件测试网:iD{]+w~ _f"rO

Selenium server需要在java1.5+环境下执行。

y,PO!L+fV0

启动selenium server

Uv `hk9F [I;o0

java-jar selenium-server-standalone-2.0a2.jar。运行java selenium rc有错51Testing软件测试网:o)J Sz3y3M#~Y

 51Testing软件测试网)hBNk6?c~ O%k

java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path!

v5Y*{ B'? H+_KG0

Please add the directory containing ''firefox.exe'' to your PATH environment51Testing软件测试网 u*v K@G&~p+Wk

variable, or explicitly specify a path to Firefox 3 like this:51Testing软件测试网 o]7y'XJZ3U

*firefox3c:\blah\firefox.exe51Testing软件测试网 xH%oWP8GV8l

 51Testing软件测试网 L}9{ d9L v)G1f

 解决办法:指定firefox执行文件路径。51Testing软件测试网X,_[o G0J}}

       selenium=newDefaultSelenium("localhost", 4444,"*firefox3 D:/Program Files/Mozilla Firefox/firefox.exe",

(^3dmDR;ae*s0

               "http://www.baidu.com");

3a sD/V ff0M!Q0

转自:http://www.51testing.com/?13997
:fc[3uv NJS0

SSw"I3LS;nw0

TAG:

 

评分:0

我来说两句

Open Toolbar