I am trying to get Selenium IDE to check some text and make sure it is Numbers Only, I have created the below (using Google) and it seems to fail each time.
Error :
assertText on css=tbody > tr:nth-child(1) > td:nth-child(1) with value regexpi:^[0-9]+$ Failed:
09:44:54
Actual value "10640355" did not match "regexpi:^[0-9]+$"
enter image description here
Can anyone tell me what I need to change, or have a step by step guide on how to add this check properly
https://www.selenium.dev/selenium-ide/docs/en/api/commands#assert-text
Regex is not supported for assert text:
https://github.com/SeleniumHQ/selenium-ide/issues/141 for details.
Workaround:
screenshot
code:
store text | css=tbody > tr:nth-child(1) > td:nth-child(1) | actualText
execute script | return RegExp('^[0-9]+$','g').test(${actualText}) | isNumber
assert | isNumber | true
I am trying to compare two CSV files, most of the time it will have same data but order of data will not be the same. Eg
csv file1
AAA,111,A1A1
BBB,222,B2B2
CCC,333,C3C3
CSV File2
CCC,333,C3C3
BBB,212,B2B2
AAA,111,A1A1
so I want to use third column as Primary key to compare other values. Report the difference. Is this possible to do it in Robotframework or Panda?
If you are making use of robotframework you need to do the following,
install robotframework-csvlib
Use Built-in Collections
Input from your question
csv file1
AAA,111,A1A1
BBB,222,B2B2
CCC,333,C3C3
csv file2
CCC,333,C3C3
BBB,212,B2B2
AAA,111,A1A1
My Solution
In the below approach, we are first reading csv into list of lists for both csv files and then comparing all the list of list items by making use of Collections KW List Should Contain Sub List, here, notice that we are passing an argument "values=True" which compares the value as well.
Code that compares 2 csv files
*** Settings ***
Library CSVLib
Library Collections
*** Test Cases ***
Test CSV
${list1}= read csv as list csv1.csv
log to console ${list1}
${list2}= read csv as list csv2.csv
log to console ${list2}
List Should Contain Sub List ${list1} ${list2} values=True
OUTPUT
(rf1) C:\Users\kgurupra>robot s1.robot
==============================================================================
S1
==============================================================================
Test CSV .[['C1,C2,C3'], ['AAA,111,A1A1'], ['BBB,222,B2B2'], ['CCC,333,C3C3']]
..[['C1,C2,C3'], ['CCC,333,C3C3'], ['BBB,212,B2B2'], ['AAA,111,A1A1']]
Test CSV | FAIL |
Following values were not found from first list: ['BBB,212,B2B2']
------------------------------------------------------------------------------
S1 | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output: C:\Users\kgurupra\output.xml
Log: C:\Users\kgurupra\log.html
Report: C:\Users\kgurupra\report.html
Assuming you've imported your CSV files as pandas DataFrames you can do the following to merge the two while retaining fundamental differences:
df = csv1.merge(csv2, on='<insert name primary key column here>',how='outer')
Adding the suffixes option allows you to more clearly differentiate between identically named columns from each file:
df = csv1.merge(csv2, on='<insert name>',how='outer',suffixes=['_csv1','_csv2'])
After that it depends on what kind of differences you are looking to spot but perhaps a starting point is:
df['difference_1'] = df['column1_csv1'] == df['column1_csv2']
this will create a boolean column which indicates True if observations are the same and False otherwise.
But there are nearly endless options for comparison.
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}.
I am running the following keyword in the robot framework:
Welcome Page Should Be Open
Run Keyword If '${BROWSER}' == 'IE' Location Should Be ${LOGIN URL IE}
Run Keyword If '${BROWSER}' != 'IE' Location Should Be ${LOGIN URL}
Wait Until Page Contains Accounts 5s
Page Should Contain Accounts
Instead of having 2 Run Keyword If statements I was wondering if robot has a else statement that could be used or and OR statement that could be used?
Cheers
Starting with version 2.7.4 of robot framework you can use ELSE when calling Run keyword if.
From the documentation:
Starting from Robot version 2.7.4, this keyword supports also optional
ELSE and ELSE IF branches. Both of these are defined in *args and must
use exactly format ELSE or ELSE IF, respectively. ELSE branches must
contain first the name of the keyword to execute and then its possible
arguments. ELSE IF branches must first contain a condition, like the
first argument to this keyword, and then the keyword to execute and
its possible arguments. It is possible to have ELSE branch after ELSE
IF and to have multiple ELSE IF branches.
For example (for clarity I'm using the pipe separated format and continuation features):
| | Run Keyword If | '${BROWSER}' == 'IE'
| | ... | Location should be | ${LOGIN URL IE}
| | ... | ELSE
| | ... | Location should be | ${LOGIN_URL}
Does anyone know how I would go about verifying that a cookie value contains a text substring in Selenium IDE?
e.g. if I had a cookie called 'MyCookie' which had as its contents 'This is my value', and I wanted to assert that the cookie contained the substring 'value', is this possible using the IDE?
Update
Solution is as follows
storeCookieByName | MyCookie | variable1
storeEval | storedVars['variable1'].indexOf('value') > 0 ? true: false|result;
verifyExpression | $(result) | true
In selenium ide storeCookieByName(name, variableName) function return the value of cookies, in this function you provide only cookies name in target column and write any variable in value column
Command | Target | value
storeCookieByName | mf_user | test
echo | ${test}
name - the name of the cookie.
storeCookieByName function Returns: the value of the cookie
In the IDE use the storeCookieByName function providing the cookie name and the variable name you want the value to store the cookie into.