I wanted to generate testing.xml file at run time and for that I need to read test case name along with test data from excel file based on flag y/n and generate testng.xml
I am not getting how or is there any listener I can use to generate testng.xml so before actual execution I will have testng read. Or if I will write a code to create xml then what will be the right place to call that code
same test data and test case name I need to pass to #dataprovider
excel :
run | test case | username | password
Y | abc1 | test1. | pwd
N. | abc2 | test2 | pwd
Related
I am trying to create a random number generator:
Command | Tgt | Val |
store | tom | tester
store | dominic | envr
execute script | Math.floor(Math.random()*11111); | number
type | id=XXX | ${tester}.${dominic}.${number}
Expected result:
tom.dominic.0 <-- random number
Instead I get this:
tom.dominic.${number}
I looked thru all the resources and it seems the recent selenium update/version has changed the approach and I cannot find a solution.
I realize this question is 2 years old, but it's a fairly common one, so I'll answer it and see if there are other answers that address it.
If you want to assign the result of a script run by the "execute script" in Selenium IDE to a Selenium variable, you have to return the value from JavaScript. So instead of
execute script | Math.floor(Math.random()*11111); | number
you need
execute script | return Math.floor(Math.random()*11111); | number
Also, in your final assignment that puts the 3 pieces together, you needed ${envr} instead of ${dominic}.
My sample feature file rather than giving data from Examples I want it to pass from csv how to achieve that can anyone help me out.
Feature file:
Feature: Rocky Search Status
Scenario Outline: Rocky Search Status with Filters
Given Open firefox and start application for Rocky Search Status
When User enters "<price_right>" and "<Carat_left>" and "<Color_right_param>" and "<Cut_right_param>" and "<Clarity_right_param>"
Then Message displayed Rocky Search Status Successful
Then Application should be closed after Rocky Search Status
Examples:
| price_right | Carat_left | Color_right_param | Cut_right_param | Clarity_right_param |
| 10000 | 1.5 | 80 | 180 | 84 |
I want the data values to be defined in CSV outside the Project.
Not directly. However, you can have a record ID (or test case number) of sorts in the Example table. You can then retrieve records from the CSV in the step code based on the ID.
Scenario Outline: Rocky Search Status with Filters
Given Open firefox and start application for Rocky Search Status
When User enters data specified in test case <tcn>
Then Message displayed Rocky Search Status Successful
Then Application should be closed after Rocky Search Status
Examples:
|tcn|
|1 |
|2 |
The "When" step will use the tcn to retrieve the corresponding record from the CSV.
You can't with Gherkin. What you can do is to give your CSV file an appropriate name, refer to the name inside your Gherkin step, and then load and read the file inside your step definition.
abc.feature
Feature: A
Scenario: 1
Given data at abc.csv
...
step-definitions.js
Given(/^data at (.*)$/, function (fileName) {
const data = jsonfile.readFileSync(`${__dirname}/${fileName}`);
// iterate over data
})
I have data that looks like the following:
assetnum | assetdesc
123 | sampledesc
432 | sample desc2
I want to insert another row with four fields so it looks like the following:
SYSNAME | OBJSTRUC | AddChange | En
assetnum | assetdesc
123 | sampledesc
432 | sample desc2
However I am unsure how to do this. Does anyone know how?
I have tried generating rows but I am unsure how to merge so that it looks like this. I have also thought of adding headers but I am unsure how to specify the header (without it being created automatically) I am quite new to Pentaho.
Thanks.
Here is a hack. Assume StepA writes the actual data into a file fileA. Before writing anything into your fileA have a Text file output step and in the content tab, Add Ending line of file field, enter the custom row you need to insert. Since the file is empty at the beginning, your last line will become the first line. Once it is done, you can write the other data as per your original source using Append flag. To set the dependency, use the Block until steps finish to block the actual write in StepA.
I have existing selenium tests written in Robot IDE Framework that I'm trying to run in Sauce Labs.
I'm using the sample test from this tutorial to see if I can get at least one test running. http://datakurre.pandala.org/2014/03/cross-browser-selenium-testing-with.html
The test passes locally, and passes all the tests on Sauce Labs, but then times out and gives and error, "Test did not see a new command for 90 seconds. Timing out.
error" because it's not disconnecting Remote Web Driver.
I've tried all of these, together and separately at the end of the "Close test browser" function:
Close all browsers
Process close
Stop selenium server
I've also tried adding ((RemoteWebDriver) getCurrentWebDriver()).quit() in one of the python functions that runs during the closing process. I'm new to Selenium and Robot Framework, so I'm not sure how to grab the Remote Web Driver.
Here is the code, in case that helps:
*** Settings ***
Test Setup Open test browser
Test Teardown Close test browser
Resource ../../Keywords/super.txt
Library Selenium2Library
Library ../../Library/SauceLabs.py
*** Variables ***
${LOGIN_FAIL_MSG} Incorrect username or password.
${COMMAND_EXECUTOR} http://username:key#ondemand.saucelabs.com:80/wd/hub
${REMOTE_URL} http://username:key#ondemand.saucelabs.com:80/wd/hub
${DESIRED_CAPABILITIES} username:name,access-key:key,name:Testing RobotFramework,platform:Windows 8.1,version:26,browserName:CHROME,javascriptEnabled:True
*** Test Cases ***
Incorrect username or password
[Tags] Login
Go to https://saucelabs.com/login
Page should contain element id=username
Page should contain element id=password
Input text id=username anonymous
Input text id=password secret
Click button id=submit
Page should contain ${LOGIN_FAIL_MSG}
[Teardown]
*** Keywords ***
Open test browser
Open browser http://www.google.com ${BROWSER} \ remote_url=${REMOTE_URL} desired_capabilities=${DESIRED_CAPABILITIES}
Close test browser
Run keyword if '${REMOTE_URL}' != '' Report Sauce status ${SUITE_NAME} | ${TEST_NAME} ${TEST_STATUS} ${TEST_TAGS} ${REMOTE_URL}
Close all browsers
Process close
Stop selenium server
You shouldn't need to do anything special to close down the connection. My guess is, there's something in your test that is preventing the browser from being closed. My recommendation is to start with a simpler example, and start from the command line. Get that working, and then work your way up to being able to run something more complex from within RIDE.
Here is a working example where I removed all of the extra stuff in the test. I am able to run this both from the command line and via RIDE on Windows. You'll have to add in your own key, however:
*** Settings ***
| Library | Selenium2Library
*** Variables ***
| #{_tmp}
| ... | name:Testing RobotFramework Selenium2Library,
| ... | browserName:internet explorer,
| ... | platform:Windows 8,
| ... | version:10
| ${CAPABILITIES} | ${EMPTY.join(${_tmp})}
| ${KEY} | <put your username:key here>
| ${REMOTE_URL} | http://${KEY}#ondemand.saucelabs.com:80/wd/hub
| ${URL} | https://saucelabs.com/login
| ${LOGIN_FAIL_MSG} | Incorrect username or password.
*** Test cases ***
| Example of connecting to saucelabs via robot
| | [Setup]
| | ... | Open Browser
| | ... | ${URL}
| | ... | remote_url=${REMOTE_URL}
| | ... | desired_capabilities=${CAPABILITIES}
| |
| | Page should contain element | id=username
| | Page should contain element | id=password
| |
| | Input text | id=username | anonymous
| | Input text | id=password | secret
| | Click button | id=submit
| |
| | Page should contain | ${LOGIN_FAIL_MSG}
| |
| | [Teardown] | Close all browsers
I am using cucumber feature file to execute or write my test cases. Issue is that I am using data table as :
| abc | 1234567890 |
| defg | New Activation – Monthly (Credit in store) |
Now issue is this that console is throwing an error that :
Cannot locate element with text: New Activation ? Monthly (Credit in store).
I am not able to understand why ? is being displayed instead of "–" .