Created
June 6, 2024 06:54
-
-
Save SarahElson/c44264acef26a1aaf72550dad125a250 to your computer and use it in GitHub Desktop.
How To Get Element by Tag Name in Selenium
This file contains hidden or 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 CloudGrid; | |
import java.net.*; | |
import java.util.HashMap; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
import org.openqa.selenium.chrome.ChromeOptions; | |
import org.testng.annotations.*; | |
public class BaseTest { | |
public RemoteWebDriver driver = null; | |
String username = System.getenv("LT_USERNAME") == null ? "<lambdatest_username>" : System.getenv("LT_USERNAME"); | |
String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "<lambdatest_accesskey>" : System.getenv("LT_ACCESS_KEY"); | |
String status = "failed"; | |
@BeforeTest | |
public void setup() { | |
try { | |
ChromeOptions chromeOptions = new ChromeOptions(); | |
chromeOptions.setPlatformName("Windows 11"); | |
chromeOptions.setBrowserVersion("124.0"); | |
HashMap<String, Object> ltOptions = new HashMap<String, Object>(); | |
ltOptions.put("build", "Get Element by TagName"); | |
ltOptions.put("name", "Get Element by TagName"); | |
ltOptions.put("w3c", true); | |
chromeOptions.setCapability("LT:Options", ltOptions); | |
driver = new RemoteWebDriver( | |
new URL("https://" + username + ":" + accessKey + "@hub.lambdatest.com/wd/hub"), chromeOptions); | |
} catch (MalformedURLException e) { | |
e.printStackTrace(); | |
} | |
} | |
@AfterTest | |
public void closeDriver() { | |
driver.executeScript("lambda-status=" + status); | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment