How to make Background keyword as a runner scenario in cucumber? - selenium

I am trying to test Amazon website with 3 scenarios on selenium with cucumber. For writing gherkin structure. I concat my login functionality with other scenarios with the Background keyword. But this time the problem is that my scenario number is decreased from 3 to 2. Basically, I want to also test the login functionality and make the terminal close and go to the other test scenarios. Instead, the code behaves login and searching product functionality as one scenario and closes its terminal.
The below gherkin language is my Amazon.feature;
Feature: To be able to shop through the website in e-commerce platform, Amazon.
Background:
Given User is on homepage
When Click accept cookies
When User click login button
When User click EmailBlank
And Enter e-mail address
And User press continue button
When User click PasswordBlank
And Enter password
And Click SignIn button
Scenario: Finding the product from the website
When Click the search button
When Write product name
When Click search button
When Filter for Shipped by Amazon
When Filter for Apple
Scenario: Adding and deleting product to cart
#the upper scenario
When Click the search button
When Write product name
When Click search button
When Filter for Shipped by Amazon
When Filter for Apple
#the upper scenario
When Click the first product
When Add to Cart
And Close the Cart
And Click the Cart
When Check at cart page
When Delete the product
I tried to put the Scenario below the Background but this time 2nd scenario is run without logging into the website. I also put Scenario before the Background and get the syntax error.

You can write an Scenario with 1 step that not exist in Background:
Scenario: Login with valid credentials
Then check some extra data here belongs to login function thaat is not included it background

Instead of writing
Given User is on homepage
When Click accept cookies
When User click login button
When User click EmailBlank
And Enter e-mail address
And User press continue button
When User click PasswordBlank
And Enter password
And Click SignIn button
write
Given I am signed in
and push HOW you sign in down into the step definitions. Once you have done that go further and push HOW you sign in down into helper methods called from your step definitions.

Related

Forgot password in Firebase Authentication (better UI/UX)

I am developing a mobile app which uses Firebase Authentication. When the user forgets his/her password, I am following these steps:
1- User is asked to enter his/her email.
2- User is forwarded to the attached screen (see image).
3- User receives an email with a link.
4- User clicks on the link in the email inside his device.
5- User is taking to another screen (in the mobile) to enter new password.
The problem I am faced with is that what if the user performs step # 4 but on his desktop.
Meaning that the user goes to his desktop and clicks on the link inside the email. In this case, the rest of the steps will resume from the desktop and the mobile app does not know if the user has changed his password. So the mobile app will remain at the attached screen. What should I do to move the user to the sign in screen.
Obviously, I can add a third button which I can call "Continue" or "Resume" which when clicked will take the user to sign in. But that has couple problems:
1- I will need to add a third button to the screen which is not super clean.
2- When the user clicks on the "Continue" or "Resume" button, there is no guarantee that the user has changed his/her password in the first place. So there is no point of clicking the button in the first place.
One other solution would be to not allow the user to change password from the desktop by providing instructions to the user to go back to the mobile device and click on the link in the email over there.
Can some one suggest a nice way to handle this situation.

when accessing the login again, the user has the same option selected (kotlin)

I have an app that I would like that when performing the login and the user selects a radio button in the option he wants, this information is already selected when he accesses the account again with the same login, only if it is the same login, if it is another perform the normal process of selecting an option.

I want to test a submission form but the click on the submit button calls on a api from a different domain in Cypress

Lets say I want to automate a lead form with name and number in cypress,
I click on Submit button
The BaseUrl is https://localhost:8080
On clicking the Submit button manually, an API is triggered with URL https://localhost:9010
But in Cypress
Api is not triggered , and no action occurs on clicking the submit button .
Can somebody give a solution or a workaround for this issue??

How do I write this BDD script?

I have an exit button in my application which I want to write a story for. It behaves this way:
If I have content filled in the form I am editing and I click on the exit button, it will pop up with a confirmation message letting me know there are unsaved content and if I am sure I want to exit from the page.
If I do not have any content filled in the form I am editing and I click on the exit button, the confirmation message will not show up and I am instantly exited from the form.
What I have so far is something like this:
Given as a User on New Profile page
And I fill in the customer name = "Bob"
When I click on the Exit button
And I click on the "Ok" in the confirmation dialog
Then I will be redirected to the landing page.
My question is the part on And when I fill in the customer name = "Bob" only covers one of the fields. How do I write the story in a succinct way that if any of the fields are filled or chosen (drop downs), the confirmation dialog will show up ? Secondly, is my story correct ?
You can use a scenario outline in conjunction with parameterizing the step that fills in a field with a dummy value.
Scenario Outline: The user is taken to the landing page after exiting new user profile
Given I am registering as a new user
And I have filled in the "<Profile Field>" field
And I have chosen to exit the current page
When I confirm I want to abandon my unsaved changes
Then I should be redirected to the landing page
Examples:
| Profile Field |
| Name |
| Phone Number |
| ... |
You didn't post the scenario title, which is just as important as the wording for each step, so I made on up. The important thing is to focus on the behavior:
Scenario Outline: The user is taken to the landing page after exiting new user profile
The step Given I am registering as a new user should navigate to the new user profile page.
The step Given I have filled in the "<Profile Field>" field should accept an argument where you name the field you want filled in. The definition for this step should fill in the field with dummy information, or blindly chose an option in a dropdown.
The step Given I have chosen to exit the current page should click the exit button. Notice there is no mention of "clicking" on anything. You should avoid language in your steps the sound like instructions on how to use the user interface, and instead focus on the behavior of the application using business terms.
Same thing for When I confirm I want to abandon my unsaved changes. It does not mention clicking on anything. It just focuses on the behavior (choosing to abandon your changes). The step definition should know how to click the "OK" button in the confirmation dialog. The fact a confirmation dialog even exists should only be known by the step definition.
Finally, Then I should be redirected to the landing page makes your assertion about where the user ends up. I like to include the word "should" in my Then steps. If find it easier to pinpoint the test failure when a Then step fails. The condition that comes after the "should" in my step is usually the thing that fails.
you can use datatable in that particular step as below
Given as a User on New Profile page
And I fill in the customer details
|name|address1|adress2|pincode| //can be accessed with DataTable datatype in SD*
When I click on the Exit button
And I click on the "Ok" in the confirmation dialog
Then I will be redirected to the landing page.
*SD-Stepdefinitions

Form Submissions via API

I have a form embedded on my website via Hubspot API. I want to receive an email notification if someone submits the form. I tried the solution given on the HubSpot community but it does seem to work.
Here it is https://developers.hubspot.com/docs/methods/forms/submit_form
https://developers.hubspot.com/docs/methods/forms/submit_form_v3
Can anybody provide a solution? TIA.
Under Marketing -> Lead Capture -> Forms, find and open the relevant form. Click the Options tab at the top and in the middle of the page locate Send submission email notifications. Select your user from the drop down list or manually enter an email.