Robot Framework - perform action until condition met - pagination

I have a scenario I am just beginning to develop automation for, but one need is to add items to the page until the table has filled and the table items are now displayed on two pages.
Once the table is filled, the count of available pages at the top right increases by one.
Thought I would reach out to see if anyone had a creative way to perform an action in Robot Framework until a condition is met - in this case I would add new fruit until the page count at top right changes to 2.
[Solution Below]
*** Settings ***
Documentation Test case to validate paginatio
Suite Teardown Close all browsers
Library Selenium2Library
Resource config.txt
*** Test Cases ***
Login
[Documentation] Log in and load Fruit Table page
Login User ${admUser} ${admPwd}
Open Browser ${URL}/fruit_table.php
Validate Pagination Feature
[Documentation] Add Fruit table until page is added
Generate New Page
*** Keywords ***
Generate New Page
wait until keyword succeeds 2 minutes 2 seconds Fill Table
Fill Table
Create Table Entry
Validate new page is available
Create Table Entry
Create New Item
Fill Out Form ${ratfrm1} ${rat1}
Fill Out Form ${ratfrm2} ${rat2}
Click Submit Button

Wait until keyword succeeds will continuously run a keyword until it succeeds. You could write a keyword that adds an element and fails until the page count changes.

Related

Can I write "or" statements in Cucumber?

I am new to using the Cucumber testing framework and am trying to test if a table contains a value in one of the cells. The value I am looking for can vary between 4 different values: Pending, Idle, Active, Unknown. How can I test to see if at least one of these values exist?
This is what I have currently but it only tests for one of the values:
Scenario: Status exists in my table
When I am in the Edge UI
And I click "Administration"
And I click "Sites"
Then I see "Site Elements"
And I see "Idle" inside table
This is what I want to be able to do:
Scenario: Status exists in my table
When I am in the Edge UI
And I click "Administration"
And I click "Sites"
Then I see "Site Elements"
And I see "Idle" or "Pending" or "Active" or "Unknown" inside table
You can make regex pattern in last row like this:
And I see (.*)
After that in method you can use ifs ose switch
Switch(parameter)
{
Case: "Idle":
// logic here
}
Yes, cucumber expressions give you the flexibility to use or's via /.
See https://cucumber.io/docs/cucumber/cucumber-expressions/#alternative-text for more information.
You should write your Cukes in a different way. Instead of using your cukes to document HOW you do something you should use them to document WHAT you are doing and WHY its important. This involves pushing all the HOW into step definitions or better yet helper methods called by step definitions.
The second thing you want a scenario to do is too actually test some behaviour. So ideally you want to do something that changes one of these states, i.e. you perfom an action that results in the value from pending to active.
All this stuff about clicking this and clicking that and seeing particular strings is a really good way to write really fragile scenarios which break whenever someone changes minor details in HOW something is done even if those changes don't break the functionality of what is being done
Scenario: Any status exists in my table
When I am in the Edge UI
And I click "Administration"
And I click "Sites"
Then I see "Site Elements"
And I see a site status inside the table
I believe this is what you are trying to communicate here. Inside your step definition, you can then check that it is one of the recognised statuses.
Given('I see a site status inside the table', function (){...})
However, if you're trying to locate each individual one, then splitting this into a Scenario Outline, and using some of the other answers here as inspiration, you can match the status that you are meant to see in each scenario:
defineParameterType(new ParameterType(
'siteStatus',
/Idle|Pending|Active|Unknown/,
String,
s => new String(s)
))
Given('I see "{siteStatus}" inside the table', function (){...})
OR
Given(/^I see "(Idle|Pending|Active|Unknown) inside the table"$/, function (){...})
Alongside
Scenario Template: Each status exists in my table
When I am in the Edge UI
And I click "Administration"
And I click "Sites"
Then I see "Site Elements"
And I see a "<status>" inside the table
Scenarios:
| status |
| Idle |
| Pending |
| Active |
| Unknown |

Dynamic Tabs in jsf based on query results

I have a situation where i have a table with multiple department entries. I will run a DISTINCT query on department names and have to create tabs in jsf page for each of the departments.When i add a new department in the table , then it should dynamically create a tab for that department.
How to achieve this?
Your help is much appreciated..Thanks
I presume your menu is based on view objects. If that's the case, then new menu tab will be available on the next time the user logs in (in case you use security) , or if you close and re-open the browser.
If you want a different behaviour, you need to code your way out: offer a 'refresh' button from where you may do a call 'Execute' action to refresh the menu on demand.
An option to get the new menu visible immediately ( though not recommended from performance perspective) would be to set the attribute CacheResult=false on the pageDef's iterator pointing towards your view object.

Change the site look based on user's list item property

We have a list containing the ADUsername and Boolean field (Yes/No) columns. Based on the logged in user we are fetching this list item and corresponding value for yes/no field.
Now we want to change the look of the SharePoint site based on this value.
Yes=Blue suitebar and top bar.
No=Green suitebar and top bar.
Possible solutions we have envisioned:
Composed looks (we have worked on this but not sure if they can be changed on run time)
Master page (creating master page with hardcoded blue/green color, but not sure if it is possible to call master page at runtime)
I believe both above methods will fail as there will be multiple users accessing the site at same time and changing the master page/composed look at run time is not feasible.
The 3rd method we were thinking of is to use Javascript on the Master Page using client object model to detect the list item (yes/no) value and change the CSS colors/file dynamically.
Let me know your views on this approach or other possible solution. Thanks.

How to check LWUITList Contains Values?

I have created LWUIT Tabs ,when the user clicks on any tab, I want to execute some logic,the logic output will be some list of items,but the problem is when the user clicks on the tab again. My tab related logic is executing continously. I want to stop that,for that I want to place if condition, that should check my list contains values or not,can any one what should be the method I need to use?
myList.getModel().getSize() > 0

Can "Excel Add-In for Coded UI Testing" help when reading test scenario data from Excel worksheet

This requires a detailed explanation.
Imagine that I have an Excel spreadsheet with test cases in one worksheet
and I may have expected (validation) messages in another (in addition to expected messages in the first worksheet).
There is also some linking between the values of fields in one to the second worksheets.
See: Welcome, <First Name> <Last Name> as an example.
You can see in the "Expected Results" field in "Test cases" worksheet the value of the field is:
"The user is taken to My Account page and following welcome message is displayed:
"&Messages!$B$1244&", where First name is Dave and Last Name is Brown."
so "&Messages!$B$1244&", denotes field B1244 in worksheet "Messages"
Now the question.
If I am given all test cases like the example below for an ecommerce web site, how can I use Coded UI Testing based on this input? Can I automate Excel, use the steps in test case worksheet and combine that with Coded UI recording of data input and verification.
I believe I would need to do manual coding, partially using recorded input steps and verifications from Coded UI recorder and possibly using manual programming for verification.
I would like to hear if others have done something similar.
I would like to incorporate this into Specflow BDD, by writing feature/user story and these test cases will be scenarios.
Any success, thoughts on using Excel test automation as data driven testing.
Thanks
Rad
Test cases worksheet named "Test cases":
=====================
Test Case Name Test Case Objective
frontstore.01-3 Register a shopper from order
confirmation page with valid inputs
# Step Data Expected Results
------------------------------------------------------------------------------------------------
1 Launch the test storefront http://testserver.com/index Welcome page is loaded.
2 Click Sign In link Sign In page is loaded.
3 Click Register under New Customer Register page is loaded.
4 Enter valid inputs and click Submit "Logon ID = TestUser
Firstname = John
Lastname = Clark
... (other fields) Registration Successful.
The user is taken to My Account page
and following welcome message is displayed:
Welcome, <First Name> <Last Name>, where First name is
David and Last Name is Brown."
Validation Messages worksheet named "Messages":
=====================
#Text used in MyAccountPages
---------------------------------------------------------------------------
MA_WELCOME Welcome, <First Name> <Last Name>
After reading a bit about Coded UI testing:
It can certainly be done, but data/sentences like:
“Launch the test storefront”
“Click Sign In link”
“Registration Successful.
The user is taken to My Account page
and following welcome message is displayed:
Welcome, , where First name is
David and Last Name is Brown."
contain both actions and data so I need to drill down into parts of the sentence to
translate it to actions and binding to parameters.
If I understand well data binding can only be used to bind column values to some parameters.
So I need some way to automatically recognize the meaning of these sentences and use some binding
from parts of it.
So if I have a sentence:
“Launch the test storefront” that would be translated to:
CurrentBrowser.Navigate(Helper.TranslateTargetUrlFrom(“test storefront”))
where “test storefront” might resolve to http://testserver.com/index storefront home
page and I can ignore Data column for URL
or I can capture Launch keyword to mean CurrentBrowser.Navigate(ColumnValue(Data)) and ignore “test storefront” part of the sentence.
“Click Sign In link” could be translated to CurrentBrowser.FindLink(“Sign In”).Click(),
so it this case I will need to know that Sign In is
the text of the link, again I need to extract “Sign In” to mean the text of a link.
I see this as pretty manual style of CodedUI where I could do small recording for some actions and rely on manual extractions of terms from
given sentences.
I would like to know how can I semantically write better test cases to allow automation. I would probably need some kind of free form
test case parser that would recognize the semantic meaning of some words like: click, navigate, launch, enter, click under etc and translate this into
code by re-using existing helper methods and recorded actions and do some manual binding, but not with the whole data value in the column, but
an extracted value.
Any idea of this kind of automation?
I think yould could do this by data binding the input parameters and just reading Excel as a datasource, you are going to need to use CodedUI for that not MTM + Fast Forward

Resources