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
Related
Is it possible to instruct Selenium to use a randomly generated value (name) for further testing?
I have only just started using Selenium and have very little knowledge on the program. I have created a script that generates a random name, I want to be able to take this name and include it in another test
hope this makes sense! appreciate anyone's input
Capture the random name to a string and make it static. Use in other tests by calling it.
Can you please post some code where exactly you stuck? Are you using Selenium Webdriver?
I'm currently running my gherkin tests with a hardcoded url browser.url("http://www.x.com");
And I run my tests via gherkin start [url]
Is there a way that I can take whatever URL I enter in my command line to start my test and make it take place of the hardcoded url in my browser.url call? I am using Selenium-webdriver and docker to execute the tests which are written in Gherkin.
Short answer is NO, unfortunately. As you pointed out, you have a hardcoded value in your URL.
But, there should be easy workarounds your problem and with minor changes that can get you to your desired outcome.
1. Since you're using WebdriverIO, which basically is a Selenium bindings implementation for NodeJS, we can actually make use of Nodes build-in objects, in our case the global object process.env.
First, in your test, go ahead and substitute the URL from browser.url("http://www.x.com"); with a variable, like so: browser.url(myUrl);.
Then, declare in your program header that variable: var myUrl = process.env.URL ?
process.env.URL : "http://www.x.com". This will tell Node: "Look, if you have this process environment variable setup, then return it, else, just give me what you had before (your hardcoded value)".
Finally, when running your test from the command line, just add the variable with your desired value, like so:
$ URL="yourUrlHere" gherkin start
2. Since you're using WebdriverIO, I would strongly advise to use their complete tool-suite to leverage a better testing experience. *looks in sadness towards that unused wdio.config.js file*
Thus, I would recommend taking a look at their Testrunner and going through the training sections. If you're keen on using Gherkin, don't worry! WebdriverIO beautifully integrates with Cucumber (as well as Mocha, or Jasmine) which uses Gherkin.
Your issue then would transform into a simple config change via the wdio.config.js file.
Let me know if this helps. I can probably muster some other solutions. Cheers!
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.
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
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.