GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - praveenLT/java-selenium-basic-auth: 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.

BranchesTags
Open more actions menu

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
src/test/com/lambdatest
src/test/com/lambdatest
 
 
.gitignore
.gitignore
 
 
.gitpod.yml
.gitpod.yml
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

How to handle basic auth for automation test in Java-selenium on LambdaTest

Java

Prerequisites

  1. Install and set environment variable for java.
    • Windows - https://www.oracle.com/java/technologies/downloads/
    • Linux - sudo apt-get install openjdk-8-jre
    • MacOS - Java should already be present on Mac OS X by default. 2 Install and set environment varibale for Maven.
    • Windows - https://maven.apache.org/install.html
    • Linux/ MacOS - Homebrew (Easier)
     install maven
    

Handling basic auth:

The following code snippet illustrates how basic auth can be handled:

DevTools devTools = ((HasDevTools) driver).getDevTools();
devTools.createSession();

driver = augmenter.addDriverAugmentation("chrome", HasAuthentication.class,
                (caps, exec) -> (whenThisMatches, useTheseCredentials) -> devTools.getDomains().network()
                        .addAuthHandler(whenThisMatches, useTheseCredentials))
                .augment(driver);

((HasAuthentication) driver).register(UsernameAndPassword.of("foo", "bar"));

Run your First Test

  1. Clone the Java-Selenium-Sample repository.
git clone https://github.com/LambdaTest/java-selenium-sample.git
  1. Next get into Java-Selenium-Sample folder, and import Lamabdatest Credentials. You can get these from lambdatest automation dashboard.

    For Linux/macOS::

export LT_USERNAME="YOUR_USERNAME"
export LT_ACCESS_KEY="YOUR ACCESS KEY"

For Windows:

set LT_USERNAME="YOUR_USERNAME"
set LT_ACCESS_KEY="YOUR ACCESS KEY"

Step 3. You may also want to run the command below to check for outdated dependencies. Please be sure to verify and review updates before editing your pom.xml file as they may not be compatible with your code.

 mvn versions:display-dependency-updates

Step 4. Run single test.

mvn clean install exec:java -Dexec.mainClass="com.lambdatest.BasicAuthentication" -Dexec.classpathScope=test -e

About LambdaTest

LambdaTest is a cloud based selenium grid infrastructure that can help you run automated cross browser compatibility tests on 2000+ different browser and operating system environments. LambdaTest supports all programming languages and frameworks that are supported with Selenium, and have easy integrations with all popular CI/CD platforms. It's a perfect solution to bring your selenium automation testing to cloud based infrastructure that not only helps you increase your test coverage over multiple desktop and mobile browsers, but also allows you to cut down your test execution time by running tests on parallel.

About

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.

www.lambdatest.com/java-automation-testing?utm_source=github&utm_medium=about&utm_campaign=java_selenium_basic_auth

Topics

automationautomation-testautomation-testingbasic-authbasic-auth-for-automation-testhandle-basic-authjavajava-seleniumjava-selenium-basic-authlambdatestseleniumselenium-javatest-automation

Resources

Readme
Activity

Stars

12 stars

Watchers

1 watching

Forks

4 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.