pm.test("success status", () => pm.response.to.be.success );
Tuesday, March 21, 2023
How to Write Effective Test Scripts for Postman API Testing
Monday, March 20, 2023
Dropdown Handling with Selenium WebDriver: Tips and Techniques
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
public class Example {
WebDriver driver;
@BeforeTest
public void setUp() {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
driver.manage().window().maximize();
driver.get("https://www.amazon.com/");
}
@Test
public void dropdownTest() {
WebElement dropdown = driver.findElement(By.id("searchDropdownBox"));
Select select = new Select(dropdown);
// Print the first selected option and assert if it equals “All Departments”.
String firstSelectedOption = select.getFirstSelectedOption().getText();
System.out.println("firstSelectedOption = " + firstSelectedOption);
if (firstSelectedOption.equals("All Departments")) {
System.out.println("PASS");
} else {
System.out.println("FAIL");
}
// Print all of the drop down options-getOptions(); method returns the List<WebElement>.
Using a loop, print all options.
List<WebElement> allOptions = select.getOptions();
for (WebElement eachOption : allOptions) {
System.out.println(eachOption.getText());
}
// Print the total number of options in the dropdown
int totalNumOfOptions = select.getOptions().size();
System.out.println("numOfOptions = " + totalNumOfOptions);
// if ‘Appliances’ is a drop-down option. Print true if “Appliances” is
// an option. Print false otherwise.
List<String> listOfOptions = new ArrayList<>();
for (WebElement eachOption : allOptions) {
listOfOptions.add(eachOption.getText());
}
System.out.println("listOfOptions = " + listOfOptions);
if (listOfOptions.contains("Appliances")) {
System.out.println("TRUE");
} else {
System.out.println("FALSE");
}
// Assert if the dropdown is in Alphabetical Order
List<String> sortedList = listOfOptions.stream().sorted().collect(Collectors.toList());
System.out.println("sortedList = " + sortedList);
}
@AfterTest
public void tearDown() {
driver.quit();
}
}
Thursday, March 16, 2023
OTP Code Verification: How to Test for Every Scenario
- Verify for verification whether valid and correct OTP is generated or not.
- Verify OTP code should be valid only for one time or not.
- Verify the count for the OTP code generated should not be more than required.
- Test the count for the OTP code generated should not be less than required.
- Verify OTP code is sent to the user successfully or not within time or not.
- Verify and confirm the time duration in which the user received the OTP-generated code sent by email.
- Check the time duration for the OTP-generated code received by the user on mobile.
- Verify the OTP code fetched by the application from the message by default or user add manually. It depends on the requirements.
- Verify by adding the valid OTP application that must accept the code successfully.
- Confirm whether the correct info message is shown or not in case if the User adds a valid OTP code.
- Verify a proper error message should be shown in case if the user adds an invalid OTP code.
- Verify OTP code should expire after the time allowed by the application or software.
- Verify application should not accept the OTP code once expired.
- Verify the user can request a new OTP code by clicking on the link or button to resend the code.
- Verify on again request on clicking on the Resend link OTP code should be sent to the user successfully or not.
- Verify whether the user should be temporarily blocked or not in case it requests for new OTP code again and again.
- Verify whether the limit is set for the OTP code to resend multiple times or not. (For example, a maximum of five attempts is allowed per user)
- Verify OTP code is case-sensitive or Not.
- Verify OTP code is only numeric or alphanumeric.
Email Field Testing: Tips and Best Practices for Effective Results
- Verify email field is present on the page.
- Verify whether the label text is shown with the email field or not.
- Verify label text email align with the email field.
- Verify that the placeholder text in the email field is added or not.
Functional Test Cases:
- Verify email address field is accessible by clicking on the email field.
- Check users can type email in the email field.
- Verify user can paste the email address in the field by keyboard keys Ctrl + v.
- Verify that the user can paste the email address with the mouse by right-clicking in the email field and pasting the email address.
- Verify validation for the email field is implemented or not.
- Verify whether an error message should be shown in case if the user adds an invalid email address or not.
Positive Test Cases:
- Validate the email field by entering a valid email address. (abc@gmail.com)
- Verify the email must contain @ in the email address.
- Verify that an email field accepts an email containing a plus + sign in the Email address.
- Verify whether an email field validates an email address containing a domain or not. (abc@gmail.com)
- Make sure there should dot present in the email address or not.
- Verify an email address should be considered correct if an email contains a subdomain.
- Check that an email address has a maximum of 2 dots in the case of the subdomain.
- Verify an email address containing a special character consider valid.
- Verify an email address having numbers is valid.
- An email address with quotes ” ” should consider valid.
- An email address may contain a dash – or underscore _.
Saturday, March 11, 2023
Simplifying Testing: The Benefits of Test Automation
Automated testing can help in the following:
- Save time and resources.
- Improve test coverage, and help catch defects earlier in the development cycle.
- Fast Execution time.
- Automated tests can run much faster than manual tests, allowing you to test more frequently and thoroughly.
- Automated test scripts can cover a larger range of scenarios and edge cases, ensuring that your software is thoroughly tested.
- Automated tests can be run consistently, reducing the risk of human error and ensuring that the same tests are run each time.
- You will agree with me on the fact that automated tests can quickly identify regression bugs that may have been introduced as a result of changes to the codebase.
- While the initial investment in creating automated tests may be higher than manual testing, the long-term benefits can outweigh the costs, as automated tests can be run repeatedly without additional costs.