cucumber - wanted to execute same scenario multiple time with multiple set of data ( data will be different ) without scenario outline - cucumber-jvm

wanted to execute below scenario multiple time with different set of user name and password without using scenario outline. As I am new to this world so need some guidance
Data source - excel file
Language - JAVA
#login
Scenario: Login with correct credential
Given open browser & enter user name and password
When validate user credential
Then application should open
And Logout to application & close browser

Scenario: Login with correct credential
Given open browser & enter user name and password
And enter<superuser> in ....
And enter<superUserPassword> in ....
Then click "dadada" button
And verify application should open
And Logout to application & close browser
Examples:
|superuser | superUserPassword |
|"superUser1" |"superPassword1" |
|"superUser2" |"superPassword2" |
|"superUser3" |"superPassword3" |

Related

Parameterisation for login feature in Karate

I want to parameterise the login feature file so that is can be used for multiple user credentials. Can anyone please help me here? Below is the code that I am using:
Given url baseUrl
And form field username = 'admin'
And form field password = 'admin'
When method GET
Then status 200
I want to parameterise the value for username and password so that it can be passed from another feature file and can be reused again.

Pass POJOs in Cucumber Example table

Description:
As a test developer, I would like to use a single scenario to test 3 different environments.
Simplified Scenario example:
#smoke
Scenario: Login to the login page and assert that the user is logged in
Given User navigates to the page
And User enters valid login credentials
When User clicks on the login button
Then Landing page can be seen
Data ( These are grabbed from a property file - converted to POJO ) :
Env1.class
url = www.environment1.com
username = john
password = doe1
Env2.class
url = www.environment2.com
username = john2
password = doe2
Env2.class
url = www.environment3.com
username = john3
password = doe3
Test Setup
Each environment has its own test runner ( failsafe )
Each environment runs in parallel.
Test runs and is built via ~mvn clean verify
Tests are property file dependant as environments may change.
Potential solution:
Is there a way to pass POJOs in the Example Table? or Cucumber's data table?
I am new to BDD and Cucumber - any help would be great. Thank you.
TLDR: is there a way to pass the Prop File variable in the Examples Table in Cucumber?
| URL | Username | Password |
| env1.getUrl | env1.getUsername | env1.getPassword |
So it'll be
#smoke
Scenario: Login to the login page and assert that the user is logged in
Given User navigates to the page <URL>
And User enters valid login credentials <Username> and <Password>
When User clicks on the login button
Then Landing page can be seen
You can use the scenario outline to run the same scenario with different data for each run. But it will be not parallel. It is sequential. The feature file is,
#smoke
Scenario Outline: Login to the login page and assert that the user is logged in
Given User navigates to the page <URL>
And User enters valid login credentials <Username> and <Password>
When User clicks on the login button
Then Landing page can be seen
Example:
|URL |UserName|Passowrd|
|www.environment1.com|john1 |doe1 |
|www.environment2.com|john2 |doe2 |
|www.environment2.com|john3 |doe3 |
You can use a single runner class. No need to use either property file nor pojo class.
You can achieve that using cucumber extension for BDD2. By using it you can have external examples or you can use properties in example as below:
| URL | Username | Password |
| ${env1.getUrl} | {env1.getUsername} | ${env1.getPassword} |
Alternate is you can use CSV or XML data provider.
In order to use pojo, you need to modify your step definition to accept either DataTable or POJO as argument. When accepting POJO as argument you need to write transformer.
When you use cucumber extension you can also use QAFTestStep which accepts POJO without addition effort. Here you can find step examples and feature file.

Run Feature file with different login

Here we need to run the same feature file with different login and provide login user name from tags.
Run the feature file with user1 and user2
#user1 #user2
Feature: Feature-1
Background :
Given I am login with user
Scenario:
Scenario:
Run the feature file with user1
#user1
Feature: Feature-2
Background :
Given I am login with user
Scenario:
Scenario:
Use Scenario Outline concept of gherkin language where you can pass user name and password as a Example. For ex:
-- Feature file
Scenario Outline: Verify Login Functionality
Given There is a user "<username>" and <password>"
When I login to the application
Examples:
|username|password|
|user1|pass1|
|user2|pass2|
-- Spec file
Given(/^There is a user (.*) and (.*)$/, async function(username, password) {
driver.findElement(Locator to identify the username element).sendKeys(username);
driver.findElement(Locator to identify the password element).sendKeys(password);
});
Here, same test scenario written above will be repeated for two different users.
Take these two regular expressions as a parameter in spec file and send it to username and password text fields using selenium

Power Query returns login form as resultset instead of content even after authentication

I am trying to scrape a website resultset to create a table with the results from that specific site. On normal login on this site i can use my credentials to access the contents of the site. Site uses HTTPS
However, when i am trying to retrieve the content of this same site through power BI (and more specific Power Query) I am presented with a resultset of two columns and two rows as if the site was asking me for credentials:
|--------------|-------------|
| Username: | |
|--------------|-------------|
| Password: | |
|--------------|-------------|
This is after i entered my credentials when power query asks for them (not returning any error of faulty input). Credentials are correctly entered. When entering bad credentials it gives an error.
I have tried the following options query wise:
Direct input of the desired website
Advanced input with Query and Content optionss in M to force POST() instead of GET().
advanced method 1 - shows login form when executed:
let
Source = Web.Page(
Web.Contents(
"https://url.htm",
[Query=
[mNo ="1234",form name="overviewDetailsForm", id="overviewDetailsForm", method="post"
]
]
)
),
Data0 = Source{0}[Data]
in
Data0
Method 2 - gives an error because option can only be used with anonymous credentials:
let
Source = Web.Page(
Web.Contents(
"https://url.htm",
[Query=
[mNo ="1234",form name="overviewDetailsForm", id="overviewDetailsForm", method="post"
]
],
[Content=Text.ToBinary()
]
)
),
Data0 = Source{0}[Data]
in
Data0
If you use the HTTP debugger Fiddler you should be able to inspect the HTTPS request your browser makes on the site. (You'll have to agree to let Fiddler install a root CA on your machine in order to MITM your internet traffic.) Does your username/password show up in the Auth or Headers tab?
You can typically set any header you want in Web.Contents and they work with Web.Page too, but be aware that some auth tokens will expire over time.
With some trial and error, you should be able to get Power Query to make the same HTTP request as your browser, and you'll get your data!

Multi Login ZF2 with multi session

I have an application with 3 different logins (3 different dashboard). Not to write duplicate code I created an adapter and a plugin to login.
Now how can I manage 3 different sessions. If I run in to login Login 1 must also be signed on dashboard 2 dashboard 3, but only on dashboard 1.
How can I handle this? multi session for multi login.
This has nothing to do with authentication (or login: know what the identity of the user is) but authorization (or access: has the user the right to access this page).
You should not manage authorization with different logins, different sessions and so on. Just use a single identity for a user and use authorization for access. Take an example with ACL or RBAC, both inside Zend\Permission.
With these permission systems, you can say: this user X is allowed to access dashboard 1 and 3. The user Y is allowed to access 1 and 2. The user Z is only allowed to visit dashboard 1.
You should use Zend\Permissions\Acl. Check section "Multiple Inheritance among Roles".
http://framework.zend.com/manual/2.0/en/modules/zend.permissions.acl.intro.html
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Role\GenericRole as Role;
use Zend\Permissions\Acl\Resource\GenericResource as Resource;
$acl = new Acl();
$acl->addRole(new Role('guest'))
->addRole(new Role('member'))
->addRole(new Role('admin'));
$parents = array('guest', 'member', 'admin');
$acl->addRole(new Role('someUser'), $parents);
$acl->addResource(new Resource('someResource'));
$acl->deny('guest', 'someResource');
$acl->allow('member', 'someResource');
echo $acl->isAllowed('someUser', 'someResource') ? 'allowed' : 'denied';
But in case you don't want to use ACL. then why don't you add into your login table a permission column an integer(1,2,3...up to 7 I think) on login add this integer to a session and on each dashboard you check for permission number if not allowed access then you redirect to login or home page.