开发者

using Selenium 2 / Web Driver with C#

I have recently been looking at using Selenium 2 / webdriver for some automated web tests. The API looks great. However is it possible to record a test through the selenium-IDE and generate C# code for webdriver. I have found some Java formatters, but can't find anyway to do this for C#.

Whilst the IDE's Export Test Case As/C# works, the code it generates is for the previous Selenium 1/RC not t开发者_JAVA技巧he new Selenium2/WebDriver API.


In the newer versions of Selenium IDE this option now exists under File > Export Test Case As...

The option is called C# (NUnit) - WebDriver Backed.

using Selenium 2 / Web Driver with C#


If you're comfortable using the API i would suggest leaving the IDE behind you. Whatever generator you will find, at some point it will generate an unmanageable mess. I would suggest to take a look at the selenium design pattern at http://code.google.com/p/selenium/wiki/DesignPatterns . For instance the pagefactory makes it pretty easy to quickly make pages accesible through properties and you will be doing so in a maintainable manner.

testcode is far more easy to refactor into maintainable code, whereas this is far more difficult for recorded testcases in selenium IDE


Maybe I'm misunderstanding something but Selenium IDE 1.0.10 under Options / Format has an entry for C# which will convert the IDE test to C# format.


1.There is a plugin that can convert selinium 1 scripts to webdrive java. Unfortuantely it is claimed that the current implementation of C# is incomplete. I think I will just use Java instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜