This repository contains example codes which will help you to know how to use selenium webdriver.

Overview

What is this Repository about?

  • This repo has example codes with Selenium 4 features.
  • Websites used for testing are: automationpractice.com, saucedemo.com and the-internet
  • This repo uses Maven as build tool and TestNG testing framework to run the tests.
  • The work in this repo is still in progress.

Need Assistance?

🌟 What you do if you like the project?

  • Spread the word with your network.
  • Star the project to make the project popular.
  • Stay updated with the project progress by Watching it.
You might also like...

A collection of bite size examples for using chrome DevTools protocol commands with Selenium Webdriver v4.

selenium-devtools-guide A collection of bite size examples for using chrome DevTools protocol commands with Selenium Webdriver v4. Chrome Devtools Pro

Aug 12, 2021

Selenium Webdriver: Page Object Model (POM) With Page Factory

Prepare Web Testing Instance or Environment Selenium Webdriver: Page Object Model (POM) With Page Factory Prerequisite software Download & Install JDK

Oct 18, 2022

A FREE Selenium course that takes you step-by-step through building a custom Selenium Framework from scratch.

A FREE Selenium course that takes you step-by-step through building a custom Selenium Framework from scratch.

Selenium For Everyone The book and code repo for the FREE Selenium For Everyone book by Kevin Thomas. FREE Book Download Chapter 1: Getting Started Th

May 10, 2022

A sample repo to help you capture JavaScript exception for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to capture JavaScript exception for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Ma

Jul 13, 2022

A sample repo to help you capture performance logs in Java-TestNG using CDP on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to capture performance logs in Java-TestNG using CDP on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Homeb

Jul 13, 2022

A sample repo to help you intercept network with Java-TestNG on LambdaTest cloud. Run Selenium tests with TestNG on LambdaTest platform.

How to intercept network with Java-TestNG on LambdaTest cloud Environment Setup Global Dependencies Install Maven Or Install Maven with Homebrew (Easi

Oct 23, 2022

A sample repo to help you set geolocation for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to set geolocation for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Home

Jul 13, 2022

A sample repo to help you emulate network control using CDP in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to emulate network control using CDP in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install M

Oct 23, 2022

A sample repo to help you handle basic auth for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to handle basic auth for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Ho

Jul 13, 2022
Comments
  • PEBCAK: Ops-er needs more instructions

    PEBCAK: Ops-er needs more instructions

    It seems that I, without any Dev background, need a little bit more documentation on how to actually run the tests in an unattended fashion.

    Assume that I fire up the Selenium Grid (confirmed that the UI is available on :4444, with three browsers waiting for instructions). How would I then get the Grid to perform tests against either the locally running JuiceShop, or a remotely hosted on?

    If I strip testng.xml down to the Selenium Grid tests, I do see jobs queued on the SGrid UI, but the browsers themselves don't appear to be getting the assignments. Instead, there's a three minute timeout, after which the queued jobs go away again.

    Logs from mvn test

    [INFO] -------------------------------------------------------
    [INFO]  T E S T S
    [INFO] -------------------------------------------------------
    [INFO] Running TestSuite
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    Aug 01, 2022 5:52:46 AM org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryTracer createTracer
    INFO: Using OpenTelemetry for tracing
    
    
    [ERROR] Tests run: 19, Failures: 3, Errors: 0, Skipped: 16, Time elapsed: 184.097 s <<< FAILURE! - in TestSuite
    [ERROR] io.github.mfaisalkhatri.tests.theinternet.FormAuthenticationTests.setupTest[remote-chrome](0)  Time elapsed: 183.981 s  <<< FAILURE!
    org.openqa.selenium.SessionNotCreatedException: 
    Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
    Build info: version: '4.3.0', revision: 'a4995e2c09*'
    System info: host: 'devsecops', ip: '127.0.2.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-110-generic', java.version: '17.0.3'
    Driver info: org.openqa.selenium.remote.RemoteWebDriver
    Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, browserVersion: 101}], desiredCapabilities=Capabilities {browserName: chrome, browserVersion: 101}}]
    Capabilities {}
    	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:587)
    	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:264)
    	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:179)
    	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:161)
    	at io.github.mfaisalkhatri.drivers.DriverManager.createDriver(DriverManager.java:75)
    	at io.github.mfaisalkhatri.tests.base.BaseSuiteSetup.setupTest(BaseSuiteSetup.java:18)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
    	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:69)
    	at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:361)
    	at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:296)
    	at org.testng.internal.invokers.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:180)
    	at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:122)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at org.testng.TestRunner.privateRun(TestRunner.java:806)
    	at org.testng.TestRunner.run(TestRunner.java:601)
    	at org.testng.SuiteRunner.runTest(SuiteRunner.java:433)
    	at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:471)
    	at org.testng.internal.thread.ThreadUtil.lambda$execute$0(ThreadUtil.java:58)
    	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    	at java.base/java.lang.Thread.run(Thread.java:833)
    Caused by: java.lang.RuntimeException: NettyHttpHandler request execution error
    	at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:76)
    	at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    	at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    	at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    	at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    	at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    	at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98)
    	at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
    	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:120)
    	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)
    	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
    	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
    	at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
    	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
    	... 25 more
    Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException: Request timeout to selenium-hub/127.0.0.1:4444 after 180000 ms
    	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
    	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096)
    	at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
    	at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
    	... 38 more
    Caused by: java.util.concurrent.TimeoutException: Request timeout to selenium-hub/127.0.0.1:4444 after 180000 ms
    	at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
    	at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50)
    	at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715)
    	at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34)
    	at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703)
    	at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790)
    	at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503)
    	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    	... 1 more
    

    Logs from selenium-hub, after three minutes

    selenium-hub    | 05:57:48.503 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "2d117effc641c9831e481049220d5e01","eventTime": 1659333468502501009,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue","http.host": "selenium-hub:4444","http.method": "POST","http.request_content_length": "223","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession","http.user_agent": "selenium\u002f4.3.0 (java unix)"}}
    selenium-hub    | 
    selenium-hub    | 05:57:48.511 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "611ee885f3e4c4e5d737154faf598a1b","eventTime": 1659333468509915752,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue","http.host": "selenium-hub:4444","http.method": "POST","http.request_content_length": "223","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession","http.user_agent": "selenium\u002f4.3.0 (java unix)"}}
    selenium-hub    | 
    selenium-hub    | 05:57:48.497 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "62ac86eb1e36b5b3f68cd7458f94281a","eventTime": 1659333468496574636,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue","http.host": "selenium-hub:4444","http.method": "POST","http.request_content_length": "223","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession","http.user_agent": "selenium\u002f4.3.0 (java unix)"}}
    

    Setup:

    • Vagrant box, for Ubuntu 20.04
    • Docker and Docker-compose, also via Ubuntu repo
    • OpenJDK 17, via Ubuntu repo
    • Maven 3.8.6, via Apache.org

    Original message: Removed. I was severely misunderstanding things.

    opened by tsluyter 5
  • Update docker-compose-v3.yml

    Update docker-compose-v3.yml

    Port for Juice Shop appears to be incorrect. By default, bkiminich/juice-shop runs on 3000, not on 3001.

    That is also the port indicated in your test suite definition, so this seems like a mistake.

    opened by tsluyter 2
  • Adding SLF4j to pom.xml

    Adding SLF4j to pom.xml

    I noticed that, during the running of the tests, there were complaints that slf4j was missing. I don't know if that's problematic, but here's a fix to grab the most recent stable version.

    opened by tsluyter 1
  • Add Test Retry using TestnNG

    Add Test Retry using TestnNG

    Since some of the tests are failing due to inconsistency and jobs needs to be triggered manually to rerun, it is good to have the retry mechanisms to retry tests for 3 times before marking them as failed.

    enhancement 
    opened by mfaisalkhatri 1
Owner
Mohammad Faisal Khatri
QA with 13+ years experience in Automation as well as Manual Testing. Passionate to learn new technologies. Open Source Contributor and Mentor.
Mohammad Faisal Khatri
A sample repo to help you handle basic auth for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to handle basic auth for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows - htt

null 12 Jul 13, 2022
A sample repo to help you clear browser cache with Selenium 4 Java on LambdaTest cloud. Run your Java Selenium tests on LambdaTest platform.

How to clear browser cache with Selenium 4 Java on LambdaTest cloud Prerequisites Install and set environment variable for java. Windows - https://www

null 12 Jul 13, 2022
A sample repo to help you run automation test in incognito mode in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to run automation test in incognito mode in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows - htt

null 12 Jul 13, 2022
A sample repo to help you handle cookies for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to handle cookies for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows - https:

null 13 Jul 13, 2022
A sample repo to help you set geolocation for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to set geolocation for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows - https

null 12 Jul 13, 2022
A sample repo to help you capture JavaScript exception for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to capture JavaScript exception for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Wi

null 12 Jul 13, 2022
A sample repo to help you find an element by text for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to find an element by text for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows

null 12 Jul 13, 2022
A sample repo to help you emulate network conditions in Java-selenium automation test on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to emulate network conditions in Java-selenium automation test on LambdaTest Prerequisites Install and set environment variable for java. Windows

null 12 Jul 13, 2022
A sample repo to help you use relative locators for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to use relative locators for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven wit

null 11 Jul 13, 2022
A sample repo to help you use CDP console in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to use CDP console in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Homebrew

null 11 Jul 13, 2022