Skip to content

Instantly share code, notes, and snippets.

@SarahElson
SarahElson / RetryFailedTests
Created April 11, 2024 05:20
How To Retry Failed Tests Using IRetryAnalyzer In TestNG
package io.github.mfaisal, the expected text is updated tostatic io.github.mfaisalkhatri.drivers.DriverManager.getDriver;
import static org.testng.Assert.assertEquals;
import io.github.mfaisalkhatri.listeners.Retry;
import io.github.mfaisalkhatri.pages.lambdatestecommerce.HomePage;
import io.github.mfaisalkhatri.pages.lambdatestecommerce.LoginPage;
import io.github.mfaisalkhatri.pages.lambdatestecommerce.SearchResultPage;
import io.github.mfaisalkhatri.tests.base.BaseSuiteSetup;
import org.testng.annotations.BeforeClass;
@SarahElson
SarahElson / TestPopups.java
Created March 20, 2024 13:16
How to Handle Modal Dialog Box in Selenium WebDriver Java
package test;
import java.util.set;
import java.util.Iterator;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.testng.Assert;
@SarahElson
SarahElson / TestModalDialogBox.java
Created March 20, 2024 12:03
How to Handle Modal Dialog Box in Selenium WebDriver Java
package test;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.testng.Assert;
import org.testng.annotations.Test;
public class TestModalDialogBox extends BaseTest
@SarahElson
SarahElson / BaseTest.java
Created March 20, 2024 11:10
How to Handle Modal Dialog Box in Selenium WebDriver Java
package test;
import java.net.*;
import java.time.Duration;
import java.util.HashMap;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
@SarahElson
SarahElson / pom.xml
Created March 20, 2024 11:09
How to Handle Modal Dialog Box in Selenium WebDriver Java
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ModalDialogBoxSeleniumJava</groupId>
<artifactId>ModalDialogBoxSeleniumJava</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
@SarahElson
SarahElson / MainPage.js
Created March 19, 2024 16:25
How To Check If An Element Exists In Cypress
export default class MainPage {
static elExists(text){
cy.get('body')
.then($body => {
if ($body.find(text).length) {
return 'text'
}
return '.both.text-reset'
@SarahElson
SarahElson / test-example.cy.js
Created March 19, 2024 16:24
How To Check If An Element Exists In Cypress
import config from './config.json'
import MainPage from '../../page-objects/components/MainPage'
describe('Elements Exist', () => {
it('Elements exist across the pages', () =>{
cy.visit(`${config.URL3}`)
//Element Exists
cy.get('body')
.then($body => {
if ($body.find('.compare-total').length) {
return '.compare-total'
@SarahElson
SarahElson / Config.json
Created March 19, 2024 16:22
How To Check If An Element Exists In Cypress
{
"URL3": "https://ecommerce-playground.lambdatest.io/index.php?route=product/category&path=57"
}
@SarahElson
SarahElson / lambdatest-config.json
Created March 13, 2024 14:06
How to Write Your First Cypress Test [With Examples]
{
"lambdatest_auth": {
"username": "username",
"access_key": "access_key"
},
"browsers": [
{
"browser": "Chrome",
"platform": "Windows 11",
"versions": [
@SarahElson
SarahElson / testng.xml file
Created February 22, 2024 06:26
Automate UI Tests With Selenium
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<!-- The XML suite file defines the structure of TestNG test suites -->
<suite name="Suite">
<test name="Test">
<!-- Classes element contains the classes to be included in the test -->
<classes>
<!-- Reference to the DemoClass test class -->
<class name="demo.DemoClass"/>
</classes>