简体   繁体   中英

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 the 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 .

导出测试用例为...子菜单

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

也许我误解了一些东西,但是选项/格式下的Selenium IDE 1.0.10有一个C#条目,它将IDE测试转换为C#格式。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM