A feature file having two individual scenarios having weird web locator problems - cucumber-jvm

I have a feature file with having two scenarios: one for login to website, another one doing some actions on the logged in page.
If I arrange the feature file with just one scenario, it is working fine, especially line highlighted in the first feature file given below.
But if the same feature file arranged as having two scenarios, it gives a web locator problem, even though in the page object code, I give the same
line of code to locate the web element.
The first scenario (with Outline) is just doing the login to the website. No objects stored, or any thing.
The second scenario is trying to verify some data on the page like whether row with userid and date being populated.
The problem is with the second feature file where I introduced the second scenario keyword, because it is rightfully
another separate scenario.
NOTE:- The code used to locate the web element in the two places (maintained as SEPARATE PROJECTS) is SAME.
Please help me identify the problem. Driving me insane.
#########------This feature file runs FINE.-----
Feature: Data Extract List Page
In order to test DataHub UI,
I want to specify the features of Extract History Page
**Scenario Outline:** Navigate to Extract History page from the List page
Given the User opens the PRAMA Datahub website
When the User types in userId "<uId>" and pacman passcode "
<pacman_passcode>"
And the User clicks on submit button
Then the User lands on page "<title>"
When status column-cell has status "Ready" value
And last run column-cell has userid and date populated (NOTE:working
fine)
And the User clicks on last run column cell of first extract record
Then the User is navigated to the Execution History
"execution_history" page
When the execution history page shows "completed" status
And the User clicks on extract record header
Then verify number of records greater than zero
And file name is a valid string
Examples:
| uId | pacman_passcode . | title |
| xxx | kT7&)cP^jhK&xze | Datahub |
###---This feature file CAN'T find a web element (the first after login)-#
**Feature:** Data Extract List Page
In order to test DataHub UI,
I want to specify the features of Extract History Page
**Scenario:** User logs in to prama datahub website
Given the User opens the PRAMA Datahub website
When the User types in userId "xxxxx" and pacman passcode
"kT7&)cP^jhK&"
And the User clicks submit button
Then the User lands on page "Datahub"
**Scenario:**Navigate to Extract History page from the Extract List page
Given User logs in to prama datahub website
When status column-cell has status "Ready" value
And last run column-cell has userid and date populated(NOTE: throwing
web element locator exception)
And the User clicks on last run column cell of first extract record
Then the User is navigated to the Execution History
"execution_history" page
UPDATE:
Just for kicks, when I commented out the suspected 'Scenario' keyword and accompanying
#Given step, which are practically not do any thing new, the web locators are found, NO PROBLEMO !
What the fun is happening here ?
There is no storage of any data from the first login scenario, no nothing.
Simply logged in, asked for the web locator.
**Feature:** Data Extract List Page
In order to test DataHub UI,
I want to specify the features of Extract History Page
**Scenario:** User logs in to prama datahub website
Given the User opens the PRAMA Datahub website
When the User types in userId "pnutala" and pacman passcode "98hgdPwYxze"
And the User clicks submit button
Then the User lands on page "Datahub"
**#Scenario:Navigate to Extract History page from the Extract List page**
**#Given User logs in to prama datahub website**
When status column-cell has status "Ready" value
And last run column-cell has userid and date populated
And the User clicks on last run column cell of first extract record
Then the User is navigated to the Execution History
"execution_history" page
When the execution history page shows "completed" status
And the User clicks on extract record header
Then verify number of records greater than zero
And file name is a valid string

This issue got figured out. The problem was due to NOT realizing that Cucumber treats every scenario as brand new browser session*
(To me it felt weird, as a feature with multiple scenarios must be
about testing a single individual story. Then why would you need to
destroy and restart and relogin to browser again and again ?
*). But from Serenity, I have a configuration to keep the browser session alive through out the life time of a feature (serenity.restart.browser.for.each=feature). Now after adjusting the initial opening condition of each scenario, all is working fine. –

Related

How to simulate drop down selection and updated table load with scrapy?

I am trying to load through the information about each stock page in investing.com starting from the drop-down list of "Dow Jones Industrial Average" on page investing.com/equities
I have been thinking about using scrapy with
options = response.css("select[class=stocksFilter] option[id=166]")
but this does not simulate a selection action.
After the selection action, I will be going through the table items one by one in #cross_rate_markets_stocks_1, and crawl those equity pages recursively
Can you point out how to simulate a click action?
The selection action is user interaction with the browser UI, but scrapy doesn't render a webpage, we cannot simulate user interaction or run Javascript with it. However, if you're interested in crawling by simulate user interaction, selenium might be a good tool for you.
Back to the question, if we are to crawl with scrapy, we should focus on requests and responses sent to/by the target website, you can log them in the Developer Tools of your browser. After you opened the Developer Tool, click the dropdown menu, you can see the corresponding request is sent to this url:
https://cn.investing.com/equities/StocksFilter?noconstruct=1&smlID=0&sid=&tabletype=price&index_id=166
It's a GET request, with index_id assigned with selected stock ID, you can get the stock ID and name from HTML element of https://investing.com/equities
'xpath of stock ID: //*[#id="stocksFilter"]/option/#id'
'xpath of stock Name: //*[#id="stocksFilter"]/option/text()'

Separating redirection logic in angular pages

In my application we have a summary page having a link to take the user to the different pages of the application. For example, we have separate pages for collecting personal details, address details, education details etc., and there is a summary page giving the summary of a student's data. Users of the application will go to the summary page and then navigate to any individual pages in case if the data is not filled up yet. After the user goes to the individual page, they can enter the required details, and upon saving the entered details, they will be eventually redirected back to the summary page.
I have implemented the above functionality as below at the moment,
When the user clicks on a link to the address details page from the summary page, I will pass the redirect url as a query string to the summary page, and upon the user saves the address details in the address page, I will redirect the user back to the summary page using the redirect url passed on the query string.
Each individual pages have a common base class
Redirection logic is present in each individual pages now. This logic checks if there was a redirection url present in the query string, then if present it will direct the user to the summary page after the user clicks on the save button on the current page.
I feel the above solution is elementary, there is potential for adding new pages to our application.
I wonder if there is anyway to implement the above requirement in a elegant way in such a way that the redirection logic is separated as a angular service, route or any other angular technique so that we dont have to do any thing extra for the new pages that will be added in the future.

Broadleaf commerce display some product to logged in users only

I am developing an e-commerce application using broad-leaf commerce.
My requirement is I have to add an product from login panel and display that product to only logged in users. Here few product products will be visible to all users (guest too) and few will be visible to only logged in users.
is there any way to do this?
Thanx soulfly1983 fou your try,but I found another alternative to do this without any customization. here is the full procedure..
Add a new category from admin panel.
Add a new page from admin panel (under content tab) and note the URL should be the same of category and page.
3 In the page click on rule tab.
4 Check the yes button in "Restrict to certain customers?"
Click +rule button and the select "match all" and select customer registered is equal to false
So this page will be visible to only guest users.
In the HTML body section of the rule (in general tab) write a message "you need to log in to view this stuff"
When user will log in successfully the user will not be able to the page , because we applied a rule that only logged out users can see the page so this time user will see the category and products added to that category.
am I doing right? any regarding this suggestion?
You can either extend the Product entity and add a field that will indicate whether that product will be visible to all users, or alternatively you could simply add an attribute for each product via the admin interface. Either way you will need to modify the UI logic so that it will take this additional field (or attribute) into consideration.

Redirecting URL assigned to Home Tab on Plone

On Plone, I am looking at establishing a User Group with an initial login page (collective.onlogin) that leads to what I hope will be the new Home Page. How do I change the Home Tab to reflect this once the authorised user has moved past the LogIn page. Currently, the home tab reflects and returns to the login page - string${globals_view/navigationRootUrl}
Where string:${globals_view/navigationRootUrl} is specified you may specify other expressions. In this case, you'll probably wish to create a BrowserView or Python Script that returns the path you want, since it sounds like there may be some real logic. Then, call that view or script rather than globals_view/navigationRootUrl.
Found that if I de-activated collective.onlogin, went to the "Change content item as default view ..." and selected the home page that I wanted, then reactivated collective.onlogin I would get what I wanted. The login page is still very vanilla, but that can wait for another day. Hope this helps the next person.

How to detect if user has switched Rails 3

A user logs into my application in a tab in a browser
They get an email and click a link which opens a new tab in the same browser and logs them in under a different email say.
If they go back to the first tab they are no longer the same user and I want the page to automatically detect this and then reload or redirect them if they are unauthorized to view the page.
Anyway to do this?
Or, if you really want to know when user is switched the tab, try this library:
visibility.js
As stated by #Hck:
add javascript code to reload page periodically (for example once per 30 seconds) – Hck
JavaScript is pretty much the only way to make pages do stuff after they're loaded. Note that in pretty much any user authentication system, a given browser will only be logged in as one user at a time, so as soon as the second tab opens, that browser will be acting as the second user - they can still see the current content of the first tab, but links (for instance) will no longer work unless the second user was also authorized to use them.
There are some JQuery plugins that do this sort of thing, like PeriodicalUpdater, or you can write your own (an example).