9

I know you can easily do this with Selenium IDE.

enter image description here

But I would like to be able to export the test script programatically. That is to convert this

enter image description here

to this

enter image description here

by doing something like:

seleniumIDE_API.export(htmlFilePath, outputPath, OutputTypes.CSHARP_NUNIT_WEBDRIVER);

The reason I want this is to reduce the number of steps that has to be taken when creating tests. So all you have to do is create the test and drop the html file into some directory.

  • 1
    I tried to solve this as well a few years back. Never did come up with a solution. You might be able to jury rig a framework that uses their parser (I assume it's in Javascript). The source code should be available. – DMart Dec 02 '15 at 15:31
  • You should read this: http://blog.reallysimplethoughts.com/2011/06/10/does-selenium-ide-v1-0-11-support-changing-formats/ – DMart Dec 08 '15 at 18:12
  • btw I did finally do this. At a high level what you do is save the tests as html files. The first thing you need to do is download and modify selenium ide. It's just JavaScript inside. You get access to the DOM and then parse out what you need. In our case, you parse the path to those html files you saved. Then you call it's export to c# function programatically. Then you have it close. That whole bit is like 15 lines of code. Next, you call csc.exe on the files you exported plus your actual runner program. Once that's done you call your runner program. The whole thing is very difficult and I –  Jun 10 '16 at 21:38
  • don't recommend it. Especially as once you're all done you will find that it doesn't work nearly as good when you export it because SEL-IDE is JavaScript but the files it exports have to be manually converted to C# Selenium Webdriver commands and only a few of them actually get exported. The others just do nothing. It wouldn't be hard to write the implementations yourself but it turns out SEL-IDE is the bastard child of Selenium. ...I jumped off that sinking ship. –  Jun 10 '16 at 21:40
  • 1
    " SEL-IDE is the bastard child of Selenium" Not sure how you figure that. – DMart Jun 13 '16 at 13:44
  • @kotomord can you be more specific on what's your request is. Do you want answer for this question or do you want the solution that was explained by the user – Madhan Mar 09 '17 at 12:39

2 Answers2

0

I don't think this is recommended to spend effort for. From Firefox 55 onwards, Selenium IDE will no longer work.

Try to use different recorders for this purpose. Cognizant QA solution Cognizant Intelligent Test Scripter does the same thing. It records and replays the action. I don't think a export would be possible, but surely you can by tweaking the code.

ArunPrakash
  • 138
  • 1
  • 7
  • Happily, Selenium IDE has been revived. https://seleniumhq.wordpress.com/2018/08/06/selenium-ide-tng/ – Ola Eldøy Aug 18 '19 at 06:00
  • Yes sometime back. But export to C# is not yet available. Java, JavaScript and Python available right now. – ArunPrakash Aug 19 '19 at 06:59
  • c# export is available as N-unit or X-unit test classes. See https://www.seleniumhq.org/selenium-ide/docs/en/introduction/code-export/ – TheRealZing Apr 06 '21 at 20:56
0

Per TheRealZing: C# export is available as N-unit or X-unit test classes. See seleniumhq.org/selenium-ide/docs/en/introduction/code-export

jlo-gmail
  • 4,453
  • 3
  • 37
  • 64