Created
November 1, 2021 06:48
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.lambdatest; | |
import java.net.URL; | |
import java.util.ArrayList; | |
import org.openqa.selenium.JavascriptExecutor; | |
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.Test; | |
public class AssertionTestOnLambdatest | |
{ | |
private static RemoteWebDriver driver; | |
private static String status; | |
@Test | |
public void hardAssertion() throws Exception | |
{ | |
String username = "Enter your user name"; | |
String accesskey = "Enter your access key"; | |
String gridURL = "@hub.lambdatest.com/wd/hub"; | |
DesiredCapabilities capabilities = new DesiredCapabilities(); | |
capabilities.setCapability("browserName", "chrome"); | |
capabilities.setCapability("version", "latest"); | |
capabilities.setCapability("platform", "win10"); | |
capabilities.setCapability("build", "AssertionError Test"); | |
capabilities.setCapability("name", "AssertionError Test"); | |
capabilities.setCapability("visual", true); | |
driver=new RemoteWebDriver(new URL("https://"+username+":"+accesskey+gridURL), capabilities); | |
driver.get("https://www.lambdatest.com/"); | |
String expectedtitle="Most Powerful Cross Browser Testing Tool Online | LambdaTe"; | |
String actualtitle = driver.getTitle(); | |
ArrayList<String> exceptionCapture = new ArrayList<>(); | |
try | |
{ | |
Assert.assertEquals(actualtitle, expectedtitle); | |
status="passed"; | |
} | |
catch(AssertionError e) | |
{ | |
status = "failed"; | |
exceptionCapture.add(e.getMessage()); | |
((JavascriptExecutor) driver).executeScript("lambda-exceptions", exceptionCapture); | |
} | |
} | |
@AfterTest | |
public void tearDown() throws Exception | |
{ | |
if (driver != null) { | |
((JavascriptExecutor) 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