All Projects → sudharsan-selvaraj → selenium-auto-wait

sudharsan-selvaraj / selenium-auto-wait

Licence: Apache-2.0 license
Utility to automatically manage all web element waits and enables to write wait-free selenium tests.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to selenium-auto-wait

SHAFT ENGINE
SHAFT is an MIT licensed test automation engine. Powered by best-in-class frameworks like Selenium WebDriver, Appium & RestAssured it provides a wizard-like syntax to increase productivity, and built-in wrappers to eliminate boilerplate code and to ensure your tests are extra stable and your results are extra reliable.
Stars: ✭ 170 (+448.39%)
Mutual labels:  selenium-java, testing-tools
pywinauto recorder
A record-replay tool to automate GUI via pywinauto
Stars: ✭ 48 (+54.84%)
Mutual labels:  ui-automation, testing-tools
page-modeller
⚙️ Browser DevTools extension for modelling web pages for automation.
Stars: ✭ 66 (+112.9%)
Mutual labels:  webdriver, testing-tools
Pywinauto
Windows GUI Automation with Python (based on text properties)
Stars: ✭ 3,175 (+10141.94%)
Mutual labels:  ui-automation, testing-tools
testcontainers
Selenide + TestContainers (Docker) sample project
Stars: ✭ 28 (-9.68%)
Mutual labels:  selenium-java, testing-tools
karate
Test Automation Made Simple
Stars: ✭ 6,384 (+20493.55%)
Mutual labels:  webdriver, testing-tools
Karate
Test Automation Made Simple
Stars: ✭ 5,497 (+17632.26%)
Mutual labels:  webdriver, testing-tools
allure-nunit
Archived - Allure adapter for NUnit framework.
Stars: ✭ 45 (+45.16%)
Mutual labels:  testing-tools
divo
Docker Integration and Validation Orchestrator for Elixir with Mix
Stars: ✭ 31 (+0%)
Mutual labels:  testing-tools
fluttertest
Custom flutter testing CLI tool for individual test runs and group testing
Stars: ✭ 15 (-51.61%)
Mutual labels:  testing-tools
Selion
Enabling Test Automation in Java
Stars: ✭ 252 (+712.9%)
Mutual labels:  webdriver
phptt
phptt a.k.a php test tools
Stars: ✭ 15 (-51.61%)
Mutual labels:  testing-tools
react-jsdom
Render React components to actual DOM nodes in Node.js
Stars: ✭ 31 (+0%)
Mutual labels:  testing-tools
vision-ui
视觉UI分析工具
Stars: ✭ 165 (+432.26%)
Mutual labels:  testing-tools
wdio-intercept-service
🕸 Capture and assert HTTP ajax calls in webdriver.io
Stars: ✭ 101 (+225.81%)
Mutual labels:  webdriver
kentan
A modular test data generator for TypeScript
Stars: ✭ 38 (+22.58%)
Mutual labels:  testing-tools
violent-webdriver
UI自动化测试暴力插件
Stars: ✭ 41 (+32.26%)
Mutual labels:  webdriver
oz
Oz is a behavioral web-ui testing framework developed to reduce test maintenance by using a predictive model rather than a scriptive model when writing tests.
Stars: ✭ 23 (-25.81%)
Mutual labels:  testing-tools
graphql-query-generator
Generates queries from the GraphQL endpoint via schema introspection.
Stars: ✭ 49 (+58.06%)
Mutual labels:  testing-tools
rtl-simple-queries
Simple wrapper queries for @testing-library/react
Stars: ✭ 20 (-35.48%)
Mutual labels:  testing-tools

selenium-auto-wait

selenium-auto-wait automatically manages all weblement waits and makes you to write wait free selenium tests.

Features

  1. Waits till element found when using findElement method. Unlike Webdriver's implicit wait method, you can control this behaviour using annotations.
  2. Waits for the element to become intractable before performing any action on it.
  3. If you using pageobject model and wants to ignore auto wait for certain methods, you can use @IgnoreWait annotation.
  4. You can use @WaitProperties annotation to control the behaviour of auto wait for a specific method in the page object method.

Installation

Maven

<dependency>
    <groupId>io.github.sudharsan-selvaraj</groupId>
    <artifactId>selenium-auto-wait</artifactId>
    <version>1.0.2</version>
</dependency> 

Gradle

implementation group: 'io.github.sudharsan-selvaraj', name: 'selenium-auto-wait', version: '1.0.2'

Also while downloading selenium, make sure to exclude net.bytebuddy:byte-buddy library by using

Maven

<dependency>
   <groupId>org.seleniumhq.selenium</groupId>
   <artifactId>selenium-java</artifactId>
   <version>3.141.59</version>
   <exclusions>
      <exclusion>
         <groupId>net.bytebuddy</groupId>
         <artifactId>byte-buddy</artifactId>
      </exclusion>
   </exclusions>
</dependency>

Gradle

implementation (group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59') {
   exclude group: 'net.bytebuddy', module: 'byte-buddy'
 }

Quickstart

Initialize the wait plugin using

SeleniumWaitOptions options = SeleniumWaitOptions.builder()
                .parseAnnotations(true)
                .defaultWaitTime(Duration.ofSeconds(30))
                .build();
SeleniumWaitPlugin<ChromeDriver> seleniumWaitPlugin = new SeleniumWaitPlugin<ChromeDriver>(new ChromeDriver(), options);
WebDriver driver =  seleniumWaitPlugin.getDriver();

That's it. Now the driver object can be used in the test.

Available options

  • defaultWaitTime (Duration) - Used as a timeout while waiting for element.
  • excludedMethods (List) - List of method names that will be ignored in auto wait.
  • parseAnnotations (Boolean) - If true, the plugin will look for @IgnoreWait or @WaitProperties annotation and manages wait based on it. Default value is false
  • packageToBeParsed (String) - if parseAnnotations is true, the plugin will parse all the methods from the stacktrace looking for annotations. If you want to search the annotations only on a specific package then you can mention it here.

Annotation Example:

public class WaitTest {
    
    public WebDriver getDriver() {
        SeleniumWaitOptions options = SeleniumWaitOptions.builder()
                .parseAnnotations(true)
                .defaultWaitTime(Duration.ofSeconds(30))
                .build();
      
        SeleniumWaitPlugin seleniumWaitPlugin = new SeleniumWaitPlugin(new ChromeDriver(), options);
        return seleniumWaitPlugin.getDriver();
    }
    
    @Test
    public void test() {
        WebDriver driver = getDriver();
        searchAmazon(driver);
        searchAmazonWithoutWait(driver);
        searchAmazonWithCustomWait(driver);
    }

    public void searchAmazon(WebDriver driver) {
        driver.get("https://www.amazon.in");
        driver.findElement(By.id("twotabsearchtextbox")).sendKeys("oneplus 7");
        driver.findElement(By.id("twotabsearchtextbox")).sendKeys(Keys.ENTER);
        driver.findElement(By.partialLinkText("OnePlus 7 Pro")).click();
        driver.switchTo().window(driver.getWindowHandles().toArray(new String[]{})[1]);
        driver.findElement(By.id("add-to-cart-button")).click();
        driver.findElement(By.id("attach-view-cart-button-form")).click();
    }
    
    @IgnoreWait // will not automatically wait for any element interaction
    public void searchAmazonWithoutWait(WebDriver driver) {
        driver.get("https://www.amazon.in");
        new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("twotabsearchtextbox")));
        driver.findElement(By.id("twotabsearchtextbox")).sendKeys("oneplus 7", Keys.ENTER);
        new WebDriverWait(driver, 10)
                .until(ExpectedConditions.presenceOfElementLocated(By.partialLinkText("OnePlus 7 Pro")));
        driver.findElement(By.partialLinkText("OnePlus 7 Pro")).click();
        driver.switchTo().window(driver.getWindowHandles().toArray(new String[]{})[1]);
        new WebDriverWait(driver, 10)
                .until(ExpectedConditions.presenceOfElementLocated(By.id("add-to-cart-button")));
        driver.findElement(By.id("add-to-cart-button")).click();
        new WebDriverWait(driver, 10)
                .until(ExpectedConditions.elementToBeClickable(By.id("attach-view-cart-button-form")));
        driver.findElement(By.id("attach-view-cart-button-form")).click();
    }

    @WaitProperties(
            timeout = 10, //custom wait time in seconds
            exclude = {"sendKeys"} // will not automatically wait for sendKeys method
    )
    public void searchAmazonWithCustomWait(WebDriver driver) {
        driver.get("https://www.amazon.in");
        driver.findElement(By.id("twotabsearchtextbox")).sendKeys("oneplus 7");
        driver.findElement(By.id("twotabsearchtextbox")).sendKeys(Keys.ENTER);
        driver.findElement(By.partialLinkText("OnePlus 7 Pro")).click();
        driver.switchTo().window(driver.getWindowHandles().toArray(new String[]{})[1]);
        driver.findElement(By.id("add-to-cart-button")).click();
        driver.findElement(By.id("attach-view-cart-button-form")).click();
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].