selenium 和webdriver_入门实践

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

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

  watir设计理念和selenium有很大差异。watir便于测试工程师快速上手,对ie支持非常好;而selenium擅长浏览器兼容性。51Testing软件测试网hf+`1o]hK]

*X7o"P!o)V}Bsp/q0

   参考:

aWd/j&zJJ [0

http://code.google.com/p/meimei/wiki/SeleniumUsage51Testing软件测试网U#v$y/S#_R4?

http://blog.csdn.net/shendl/archive/2009/03/08/3969750.aspx

"]s"R,rpMDDE0

http://blog.csdn.net/shendl/archive/2009/03/08/3969750.aspx51Testing软件测试网.P8mx'`.h ppW

http://www.ibm.com/developerworks/cn/java/j-lo-selenium/

)i.e/W)NMz#i3u0

http://www.onlymarshall.com/tag/selenium/51Testing软件测试网:XZ3k#v a(R!t

扩展http://xace.javaeye.com/blog/57972251Testing软件测试网a,wxCh3{|5Jo

 

s8w:Y(E-t0

http://code.google.com/p/selenium/downloads/list下载selenium-server-standalone-2.0a2.jarselenium-server-standalone-2.0a2.jar

S/Q9\F]F a0

 

%RNqhydcY5E!zaZ/C0

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

+x(J(EU,~"o0

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

0J-P9h{E/d#n0

1       webdriver错误:51Testing软件测试网0yc^eax8o2B-@i

Exception in thread "main"org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed.

9~V8h g2d2|E%d UO"c0

 解决办法:指定firefox执行文件入系统属性。

Kcc%I5o-~4\,?0

    System.setProperty("webdriver.firefox.bin","D:/Program Files/Mozilla Firefox/firefox.exe");51Testing软件测试网 P*T7[yS h

       WebDriver driver =newFirefoxDriver();

2h3{Up9Tq.O)k L0

       
k9L {3`.vl1K0
51Testing软件测试网V.JLS fGQ1Gv

2       解决selenium错误:51Testing软件测试网T,i!vE$PC$O

 

vzRV8`0

下载样例代码http://www.ibm.com/developerworks/cn/java/j-lo-selenium/51Testing软件测试网2I"^4^.k*cy?{r [Q

Selenium server需要在java1.5+环境下执行。51Testing软件测试网 k5Ap}*z)y,I+xmJ

启动selenium server

[n@#d)J^2Y3T0

java-jar selenium-server-standalone-2.0a2.jar。运行java selenium rc有错

g4HZI7R)y0

 

e9}pz3?2N,G0

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!51Testing软件测试网s b!qHu6@6tdW

Please add the directory containing ''firefox.exe'' to your PATH environment

tHdg7}mZ0

variable, or explicitly specify a path to Firefox 3 like this:

%VfH~/YX0

*firefox3c:\blah\firefox.exe51Testing软件测试网+ep;[r }9it

 51Testing软件测试网 S*cu l vv3b9Q#C XU/d:r

 解决办法:指定firefox执行文件路径。

@V3H][0` C0

       selenium=newDefaultSelenium("localhost", 4444,"*firefox3 D:/Program Files/Mozilla Firefox/firefox.exe",51Testing软件测试网om!~ l ep4Up8f,[

               "http://www.baidu.com");51Testing软件测试网/e0a3^k i!]l Mx"O

转自:http://www.51testing.com/?1399751Testing软件测试网-JC"C5\.\J

k^7F;k'D+XmM0

TAG:

 

评分:0

我来说两句

Open Toolbar