Before we start with LambdaTest, let’s talk about Cross Browser testing.
Cross browser testing is testing the same application on different browser and different platforms. It is always recommended to check how the application will behave in different environments and with different browsers.
There might be some features/functionality of the application which is not supported with the new browser or lower version of that browser. In order to qualify our application for multiple platforms and environment, we should perform cross-browser testing.
Note- If your application does not support multiple browsers then better not to perform cross browser.
Now In order to do cross-browser testing in your system, you must set up everything from scratch like setting up all platforms with all browsers and setting up the device which is not an easy task.
There are many companies in the market which provide all infrastructure with different pricing options.
LambdaTest is a cloud-based online cross browser testing tool which provides all platforms with a different browser and device combinations as well. LambdaTest provides more than 2000+ combination which can be used for your test.
LambdaTest also allows you to test application running on the public and private network.
LambdaTest provide below features with simple steps
- Automation testing- We will see this with Selenium (Java Binding)
- GeoLocation Testing
- Resolution display testing
- Visual testing
- Test Responsive application
- Test internal applications
- Provide screenshots of test.
Cross Browser Testing in Selenium With LambdaTest
Please follow the below steps in order to run your automated test
- Create an account with LambdaTest (See the pricing option)
- Select device and browser combination
- Get your username and access key from Dashboard
- Create your test and use your credentials & desired capability depends on your platform and browser combination
- Execute the test
- Analyze the result
Note- LambdaTest allows you to capture a different level of logs like network log, Selenium log, etc. It also provides screenshot and video of the test which executed.
A detailed video on this topic which helps you to give a brief idea about LambdaTest and its features.
Log in with your credentials and you will be able to see the Dashboard page
Click on automation option> Click on Key Option on right panel > Get the username and access key
Now you can pass username and password in URL which will authenticate your account and you can access LambdaTest.
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import java.net.URL;
public class TestNGTodo{
// Update username from your account
public String username = "YOUR_USERNAME";
// Update access key from your account
public String accesskey = "YOUR_ACCESS_KEY";
public static RemoteWebDriver driver = null;
// This is LambdaTest grid url which will be same for all users
public String gridURL = "@hub.lambdatest.com/wd/hub";
boolean status = false;
@BeforeClass
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("version", "70.0");
capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
capabilities.setCapability("build", "LambdaTestSampleApp");
capabilities.setCapability("name", "LambdaTestJavaSample");
capabilities.setCapability("network", true); // To enable network logs
capabilities.setCapability("visual", true); // To enable step by step screenshot
capabilities.setCapability("video", true); // To enable video recording
capabilities.setCapability("console", true); // To capture console logs
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 testSimple() throws Exception {
try {
//Change it to production page
driver.get("https://lambdatest.github.io/sample-todo-app/");
//Let's mark done first two items in the list.
driver.findElement(By.name("li1")).click();
driver.findElement(By.name("li2")).click();
// Let's add an item in the list.
driver.findElement(By.id("sampletodotext")).sendKeys("Yey, Let's add it to list");
driver.findElement(By.id("addbutton")).click();
// Let's check that the item we added is added in the list.
String enteredText = driver.findElementByXPath("/html/body/div/div/div/ul/li[6]/span").getText();
if (enteredText.equals("Yey, Let's add it to list")) {
status = true;
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
@AfterClass
public void tearDown() throws Exception {
if (driver != null) {
((JavascriptExecutor) driver).executeScript("lambda-status=" + status);
driver.quit();
}
}
}
Above code is just a sample code but all you need to focus on below line and capability as well
driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
You can also start your automated test using LambdatTest.
Navigate to https://www.lambdatest.com/ and you can create an account and start using.
(Coupon code for the discount is – SOCIAL20)
You can also refer their official documentation and Capability Generator (Awesome UI-must use)
medomystica says
Nice blog. From this blog I have learnt more information. Keep updating this for more.
Mukesh Otwani says
Hi Medomystica,
You’re most welcome…:)