Git Product home page Git Product logo

praveenlt / java-testng-cdp-device-mode Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 4.0 8 KB

A sample repo to help you set device mode using CDP in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

Home Page: https://www.lambdatest.com/java-automation-testing?utm_source=github&utm_medium=about&utm_campaign=java_testng_cdp_device_mode

Java 100.00%
appium automation java selenium testing java-testng-cdp-device-mode automation-test java-testng lambdatest test-automation cdp-device cdp-device-mode device-mode-using-cdp set-device-mode

java-testng-cdp-device-mode's Introduction

How to set device mode using CDP in Java-TestNG automation test on LambdaTest

Environment Setup

  1. Global Dependencies
    $ install maven
    
  2. Project Dependencies
    • checkout the repository
    • Check that packages are available
    $ cd Java-TestNG-Selenium
    
    • 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
    

LambdaTest Authentication Credentials: Make sure you have your LambdaTest credentials with you to run test automation scripts with Jest on LambdaTest Selenium Grid. You can obtain these credentials from the LambdaTest Automation Dashboard or through LambdaTest Profile.

Set LambdaTest Username and Access Key in environment variables.

  • 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"
    

Override device mode

To override device mode, the following code can be used

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

devTools.send(Emulation.setDeviceMetricsOverride(414, 736, 50, true, Optional.empty(), Optional.empty(),
   Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(),
   Optional.empty(), Optional.empty()));

Running Tests

To run single test
    $ mvn test -D suite=single.xml -Dtestng.dtd.http=true

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.

java-testng-cdp-device-mode's People

Contributors

praveenlt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.