What exactly is selenese html? - selenium

I have been using selenium IDE to do some web app testing. I have been encountering errors on trying to playback the user actions, but have not been able to fix them because I have no idea what makes up selenese html targets and commands. It does not look like normal html to me but I cannot figure it out. If someone would be so kind as to help me I would be very happy.
Thanks in advance

Selenese is a high level, cross-platform and language-independent convention for representing Selenium commands.
The term ''Selenese HTML'' is less to do with how you'd target elements in the HTML user interface of the application under test and is more a description of how the commands are formatted.
So, I use the term ''Selenese HTML'' to distinguish it from Selenese in other languages/formats such as Selenese PHP, Selenese Java etc.
There are up to 3 components to a Selenese command:
commandName
1st argument (required by some commands)
2nd argument (required by some commands)
Given this knowledge, we can write the command in HTML format as a row of an HTML table, where each cell of the row represents a component of the command
----------------------------------------------
| commandName | 1st argument | 2nd argument |
----------------------------------------------
Now that the command is written in HTML form, we could potentially share it on the World Wide Web so that both humans and machines can read and understand it.

It's just a table definition with three tds per tr, specifying the command and any other parameters needed.
Example from the docs:
<table>
<tr><td>open</td><td></td><td>/download/</td></tr>
<tr><td>assertTitle</td><td></td><td>Downloads</td></tr>
<tr><td>verifyText</td><td>//h2</td><td>Downloads</td></tr>
</table>
The IDE also has a reference built into it. I suggest you peruse the documentation available on their site until you are comfortable with the way the IDE works -- it can be a little unintuitive if you haven't done so.

The Selenium Reference page would be a good place to start to learn about what all the various commands do and how to use them.

Related

How to define multiple steps w/ the same expression but different implementations in WebDriverIO + Cucumber.js?

We are building our automated end-to-end tests following the page object model approach using WebdriverIO and Cucumber.js. We have a number of features that have the same step expressions, like "Then I should see a 'Continue' button displayed". Each feature corresponds to a different page object so the implementation would be different.
Is there a way to scope a step definition function to a specific feature and/or scenario?
The work-around for this is ugly and means we have to add a bunch of superfluous words to the step expression to make each one globally unique.
We are using:
#wdio/cli 7.2.3
#wdio/cucumber-framework 6.11.1
react 16.14.0
typescript 4.2.3
Cucumber is meant to be a communication tool, not an implementation tool, and thus doesn't allow for ambiguous step definitions in this way
You ideally want a terse library of steps that cover scenarios in more generalised language so that you can drill down into the problems further down.
You should be aiming to describe Givens as prerequisites, Whens as user actions through the journey and Thens as what the user should expect to encounter as your journey completes, such as:
Given Jane logs into her account
When she completes the example form
Then she should see an example form confirmation page with the following information:
| status | closed |
| description | an example |
| name | Jane |
Which is something that is easily read by the business peoples, and clearly defines the intent of the test that you have written.
"I should see a continue button" seems like something that would be present in an integration test, rather than an end to end test, and would be better suited to a test in something akin to Mocha
If you wish to keep your language (however much I believe it shouldn't be within the Gherkin level), I'd recommend going through the text of the element and finding any button with the corresponding text that the step has provided, as it should be the only one on the page that has that text.
This can be achieved with xpath's contains:
//button[#class='confirmation'][contains(text(), buttonText)] where buttonText is the string captured by the step definition

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/

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

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