Created
January 9, 2022 18:25
Revisions
-
veenadevi created this gist
Jan 9, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ package LambdaTest; import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; public class TestCaseRunToCloudGrid { public RemoteWebDriver driver = null; public String username = "";//LambdaTest userName public String accesskey = "";//LambdaTest Accesskey public String gridURL = "@hub.lambdatest.com/wd/hub"; @BeforeTest public void setUp() throws Exception { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("browserName", "Chrome"); capabilities.setCapability("browserVersion", "97.0"); HashMap<String, Object> ltOptions = new HashMap<String, Object>(); ltOptions.put("user",username); ltOptions.put("accessKey",accesskey); ltOptions.put("build", "Selenium 4 grid Sample"); ltOptions.put("name", "Selenium 4 grid Sample"); ltOptions.put("platformName", "Windows 11"); ltOptions.put("selenium_version","4.0.0"); capabilities.setCapability("LT:Options", ltOptions); 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 firstTestCase() { try { System.out.println("Logging into Lambda Test Selenium PlayGround page "); driver.get("https://www.lambdatest.com/selenium-playground/simple-form-demo"); WebElement messageTextBox = driver.findElement(By.cssSelector("input#user-message")); messageTextBox.sendKeys("Welcome to cloud grid"); WebElement getValueButton = driver.findElement(By.cssSelector("#showInput")); getValueButton.click(); System.out.println("Clicked on the Get Checked Value button"); } catch (Exception e) { } } @AfterTest public void closeBrowser() { driver.close(); System.out.println("The driver has been closed."); } }