Skip to content

Instantly share code, notes, and snippets.

View muditlambda's full-sized avatar

Mudit Singh muditlambda

View GitHub Profile
@Test
public void test_login_using_relative_locators_3(){
WebElement txt_name = driver.findElement(withTagName("input")
.toLeftOf(By.id("addbutton"))
.below(By.name("li5")));
txt_name.sendKeys("Relative locators test");
// Get details of the Submit/Add button
WebElement submitbutton = driver.findElement(By.xpath("//*[@id=\'addbutton\']"));
WebDriver driver = new ChromeDriver();
Or
WebDriver driver = new FirefoxDriver();
Or
WebDriver driver = new EdgeDriver();
WebDriver driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + "@hub.lambdatest.com/wd/hub"),
DesiredCapabilities.firefox());
public String username = "yadneshshah91"; //your LambdaTest username
public String accesskey = "1234ABCD"; //your LambdaTest access key
public static RemoteWebDriver driver = null;
public String gridURL = "@hub.lambdatest.com/wd/hub"; //LambdaTest Hub URL
boolean status = false;
//Setting up capabilities to run our test script
@Parameters(value= {"browser","version"})
@BeforeClass
// Closing the browser session after completing each test case
@AfterClass
public void tearDown() throws Exception {
if (driver != null) {
((JavascriptExecutor) driver).executeScript("lambda-status=" + status);
driver.quit();
}
}
//Verifying elements on Registration page
@Test
public void verifyElemntsOnPageTest()
{
WebElement lambdaTestLogo = driver.findElement(By.xpath("//p[@class='signup-titel']"));
lambdaTestLogo.isDisplayed();
WebElement signUpTitle = driver.findElement(By.xpath("//p[@class='signup-titel']"));
signUpTitle.isDisplayed();
// Registration with all valid data
@Test
public void validRegistrationTest(){
WebElement companyName = driver.findElement(By.name("organization_name"));
companyName.sendKeys("TestCompany");
WebElement fullName = driver.findElement(By.name("name"));
fullName.sendKeys("TestName");
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite thread-count="3" name="LambaTestSuite" parallel="tests">
<test name="FirefoxTest">
<parameter name="browser" value="firefox"/>
<parameter name="version" value="69.0"/>
<classes>
<class name="com.lambdatest.SignUpTest"/>
</classes>
// Registration without providing Company Name field
@Test
public void emptyCompanyNameTest()
{
WebElement companyName = driver.findElement(By.name("organization_name"));
companyName.sendKeys("");
WebElement fullName = driver.findElement(By.name("name"));
fullName.sendKeys("TestName");
//Verifying redirection to the terms and conditions page
@Test
public void termsRedirectionTest()
{
WebElement termsLink = driver.findElement(By.xpath("//a[contains(text(),'Terms')]"));
termsLink.click();
Set <String> allWindows = driver.getWindowHandles();
for(String handle : allWindows)