Sunday, 24 February 2019

Mobile Compatibility testing using Selenium Web Driver JAVA

Here I Show you how can you perform different type of mobile browser testing with using chrome driver and in chrome Browser.

import java.io.File;
import java.util.HashMap;
import java.util.Map;


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;

public class MobileTesting{


public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub

Map<String,String> mobileEmulation = new HashMap<String,String>();
mobileEmulation.put("deviceName","Galaxy S5");
Map<String,Object> chromeOptions = new HashMap<String,Object>();
chromeOptions.put("mobileEmulation", mobileEmulation);

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
ChromeDriverService service = new ChromeDriverService.Builder()
                .usingDriverExecutable(new File("C:\\Users\\testing\\Desktop\\ChromeDriver\\chromedriver.exe"))
                .usingAnyFreePort()
                .build();



WebDriver driver = new ChromeDriver(service,capabilities);
driver.get("http://www.google.com");


}

}



Single Test case Run parallel with TestNG Framework

1) Create TestNG class. package com.software.testing; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome....