Skip to content

Instantly share code, notes, and snippets.

@muditlambda
Created January 18, 2022 16:28
Show Gist options
  • Save muditlambda/9a2be31f9564ca0d590d2657326a875a to your computer and use it in GitHub Desktop.
Save muditlambda/9a2be31f9564ca0d590d2657326a875a to your computer and use it in GitHub Desktop.
package LambdaTest;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Reporter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
public class automateCaptchaInSelenium {
public String username = "YOUR USERNAME";
public String accesskey = "YOUR ACCESSKEY";
public static RemoteWebDriver driver = null;
public String gridURL = "@hub.lambdatest.com/wd/hub";
@BeforeClass
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("version", "96.0");
capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
capabilities.setCapability("build", "AutomationUsingFindElement");
capabilities.setCapability("name", "AutomationUsingFindElementSuite");
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());
}
Reporter.log("Logging into Selenium Playground", true);
}
@Test
public void findElementByTagName() {
try {
System.out.println("Logging into Lambda Test Table Pagination Demo Page");
driver.get("https://www.lambdatest.com/selenium-playground/table-pagination-demo");
WebElement selectDropdown=driver.findElement(By.tagName("select"));
Select select = new Select(selectDropdown);
select.selectByVisibleText("10");
System.out.println("Changed the pagination dropdown to 10");
} catch (Exception e) {
}
}
@AfterClass
public void closeBrowser() {
driver.close();
Reporter.log("Closing the browser", true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment