Created
December 29, 2021 11:41
-
-
Save muditlambda/c838a797df22879889cb7870e2d664cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pages; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
import org.TestNG.Assert; | |
import org.TestNG.annotations.AfterTest; | |
import org.TestNG.annotations.BeforeTest; | |
import org.TestNG.annotations.Parameters; | |
import org.TestNG.annotations.Test; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.util.List; | |
import java.util.concurrent.TimeUnit; | |
public class DemoTest1 { | |
String username = "YOUR_USERNAME"; //Enter your username | |
String accesskey = "YOUR_ACCESSKEY"; //Enter your accesskey | |
static RemoteWebDriver driver = null; | |
String gridURL = "@hub.lambdatest.com/wd/hub"; | |
String urlToTest = "http://labs.lambdatest.com/selenium-playground/"; | |
@BeforeTest | |
@Parameters("browser") | |
public void setup(String browser) { | |
System.out.println("Setting up the drivers and browsers"); | |
DesiredCapabilities capabilities = new DesiredCapabilities(); | |
if(browser.equals("Chrome")) { | |
capabilities.setCapability("platform", "Windows 10");// To specify the OS | |
capabilities.setCapability("browserName", "Chrome"); //To specify the browser | |
capabilities.setCapability("version","94.0"); //To specify the browser | |
capabilities.setCapability("build", "ChromeTests"); //To identify the test | |
capabilities.setCapability("name", "Parallel_JUnit5Tests"); | |
} | |
else if (browser.equals("Firefox")){ | |
capabilities.setCapability("browserName", "Firefox"); //To specify the browser | |
capabilities.setCapability("version", "93.0"); //To specify the browser version | |
capabilities.setCapability("platform", "Windows 10"); // To specify the OS | |
capabilities.setCapability("build", "FirefoxTests"); //To identify the test | |
capabilities.setCapability("name", "Parallel_JUnit5Tests"); | |
} | |
else if (browser.equals("Edge")){ | |
capabilities.setCapability("browserName", "MicrosoftEdge"); | |
capabilities.setCapability("platform", "Windows 10"); | |
capabilities.setCapability("version","94.0"); // To specify the OS | |
capabilities.setCapability("build", "EdgeTests"); //To identify the test | |
capabilities.setCapability("name", "Parallel_JUnit5Tests"); | |
} | |
capabilities.setCapability("network", true); // To enable network logs | |
capabilities.setCapability("visual", true); // To enable step by step screenshot | |
capabilities.setCapability("video", true); // To enable video recording | |
capabilities.setCapability("console", true); // To capture console logs | |
try { | |
driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities); | |
} catch (MalformedURLException e) { | |
System.out.println("Invalid grid URL"); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} | |
} | |
@Test | |
public void test1(){ | |
// Code Implementation | |
} | |
@Test | |
public void test2(){ | |
//Code Implementation | |
} | |
@Test | |
public void test3(){ | |
//Code Implementation | |
} | |
@AfterTest | |
public void tear(){ | |
driver.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment