Storing html source or contents of a variable in selenium ide? - selenium

I am trying to build a macro in selenium ide that stores the page source to a file. I see there is a command storeHtmlSource() that stores the page source to a variable, but I can't figure out how to store the contents of the variable to a file. Is there some direct way to do this or do I need to somehow have it execute javascript to do that?
I am totally new to selenium if that was not already obvious, but I have looked around the docs for a while and haven't figured it out.

Unfortunately you can not do this with Selenium IDE. The IDE has not been designed to do things like this since there is Selenium Rc that allows you to do what the IDE can do and more since you use your favourite language to speak to a proxy and then use that language's ability to write things to the disk.
The IDE is designed to help you get the skeleton of a test case with the record function, you then tweak it, replay to see it works and then export to your favourite language

Related

Programatically export Selenium IDE Test Suite to C#?

I know you can easily do this with Selenium IDE.
But I would like to be able to export the test script programatically. That is to convert this
to this
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.
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.

How to give proper syntax in webdriver?

I'm able to automate using webdriver but there are few syntax like
driver.manage().setscriptTimeout(100, Seconds);
(copied from other site). How to know that after manage(), setscriptTimeout() follows?
That means how to predict correct methods for timeouts or something like that in webdriver.
Copy paste can be done, but few companies doesn't prefer copy paste job, they need genuine testers who can put the syntax in brain. Please let me know how to master syntax.
What language are you using? An IDE such as IntelliJ (Java), Rubymine(Ruby), Visual STudio(C#), etc. will give you auto complete (also known as Intellisense)

Selenium IDE: pick up a database value

I made a test case with Selenium IDE that makes 25 addresses using a while-loop; starting with housenumber 1.
What I actually would like is that the maximum housenumber is picked up from the database, so we can reuse this case endlessly.
In SQL: select max(housenumber) from tbl_address where streetname = ‘Testingstreet’;
Is this possible, and if so… how?.
(As Slanec pointed out, the comments should probably be an answer).
This is way outside the scope of the IDE. You have reached a point where the IDE is not capable of doing what you want your tests to do, therefore you will either have to workaround this issue somehow, or (better IMO), scrap the IDE altogether and use WebDriver & a programming language directly.
I would use the IDE to export your current tests into whatever language you want, then use the language to find out some library or API that allows you to connect to the database.
Usually, keeping to the same programming language and database libraries as your application under test uses, is a good idea.
One way around the limitations in IDE is to create an internal webpage that you can pass queries through to your db and return the response as a table. Interacting through that page would get you the data you need.
Like the answers before me, I suggest going with the WebDriver, but if you MUST use IDE this could be a solution for you!

Using Selenium commands within a command?

I'm using Selenium IDE and would like to know if it is possible to use a Selenium command, within a Selenium command.
For example to use verifyElementPresent('someelement') within a storeEval command to store true/false.
I know this could be using JS, but using Selenium IDE's built in commands would be very time-saving!
If I understand correct, you want to create Selenium Nested function. The answer is No, it cann't.
For the SeleniumIDE reference, you will see that there are 3 parts of command (command, target, value). it also no function to store the command result, if you see the HTML code when you create the Selenium test script, you will see that it totally seperated the command to three sections.
I cannot find the document that selenium said it doesn't support to create the nested function. However, it will be get more complexity when you going to test something but the test script itself already complex. I would suggest you to store something you needs in user-extension.js, otherwise, done it by test script in your programming language you want.
Selenium have command storeElementPresent(locator, variable)
See http://release.seleniumhq.org/selenium-core/0.8.0/reference.html

Selenium IDE - Unable to Convert the recorded case from HTML to Non HTML one by one sequencially

Steps:
Record 5 Test Cases.
Open Test suite.
Select the 1st case and goto Option --> Format --> JUnit4 (Converted properly)
Copy the source.
Select the 2nd Case.
It shows Junit and HTML all mixed up. If I close the selenium IDE and open it again it allows me to convert 1 case. i.e i need to restart the IDE for each case conversion. It seems to be a bug in Selenium IDE.
I need to convert hundreds of cases. Are there any alternate method to convert cases quickly?
Thanks in advance!
Selenium now shows that it does not recommend changing the format from HTML to copy paste it. It recommends instead to export them as new files, which does work fine. The problem with this, and with what you were doing, is that it is quite slow. However, somebody (not me) created an addon to help with batch exporting of IDE files into whatever format the IDE supports. I only tested it with TestNG, but it worked like a charm for me. Download link: https://addons.mozilla.org/en-US/firefox/addon/test-suite-batch-converter-sel/