1package OrangeHrmFeature;2import org.openqa.selenium.MutableCapabilities;3import org.openqa.selenium.chrome.ChromeDriver;4import org.openqa.selenium.chrome.ChromeOptions;5import org.openqa.selenium.edge.EdgeDriver;6import org.openqa.selenium.edge.EdgeOptions;7import org.openqa.selenium.firefox.FirefoxDriver;8import org.openqa.selenium.firefox.FirefoxOptions;9import org.openqa.selenium.ie.InternetExplorerDriver;10import org.openqa.selenium.ie.InternetExplorerOptions;11import org.openqa.selenium.remote.DesiredCapabilities;12import org.openqa.selenium.remote.RemoteWebDriver;13import org.openqa.selenium.safari.SafariOptions;14import java.net.MalformedURLException;15import java.net.URL;16public class BrowserSelector extends Utils {17 public static LoadProps loadProps = new LoadProps();18 public static final String USERNAME = loadProps.getProperty("SAUCE_USERNAME");19 public static final String ACCESS_KEY = loadProps.getProperty("SAUCE_ACCESS_KEY");20 public static final String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.eu-central-1.saucelabs.com:443/wd/hub";21 public static final boolean SAUCE_LAB = Boolean.parseBoolean(System.getProperty("Sauce"));22 String browser = System.getProperty("browser");23 public void setUpBrowser() {24 System.out.println(USERNAME);25 System.out.println(ACCESS_KEY);26 //if sauce lab is true in TestDataConfig.properties.............................................................27 if(SAUCE_LAB)28 {29 System.out.println("Running in Saucelab...........with browser "+browser);30 if(browser.equalsIgnoreCase("Chrome"))31 {32 MutableCapabilities sauceOptions = new MutableCapabilities();33 ChromeOptions caps = new ChromeOptions();34 caps.setExperimentalOption("w3c",true);35 caps.setCapability("platformName","Windows 10");36 caps.setCapability("browserVersion","77.0");37 caps.setCapability("sauce:options",sauceOptions);38 try39 {40 driver = new RemoteWebDriver(new URL(URL), caps);41 }42 catch (MalformedURLException e)43 {44 e.printStackTrace();45 }46 }47 else if(browser.equalsIgnoreCase("IE"))48 {49 DesiredCapabilities caps = DesiredCapabilities.internetExplorer();50 caps.setCapability("platform","Windows 10");51 caps.setCapability("version","11");52 try53 {54 driver = new RemoteWebDriver(new URL(URL), caps);55 }56 catch (MalformedURLException e)57 {58 e.printStackTrace();59 }60 }61 else if (browser.equalsIgnoreCase("FireFox"))62 {63 DesiredCapabilities caps = DesiredCapabilities.firefox();64 caps.setCapability("platform","Windows 7");65 caps.setCapability("version","56");66 caps.setCapability("name","Testing on Firefox 56");67 try68 {69 driver = new RemoteWebDriver(new URL(URL),caps);70 }71 catch (MalformedURLException e)72 {73 e.printStackTrace();74 }75 }76 else if(browser.equalsIgnoreCase("Safari"))77 {78 DesiredCapabilities caps=DesiredCapabilities.safari();79 caps.setCapability("platform","os x 10.10");80 caps.setCapability("version","8.0");81 try82 {83 driver = new RemoteWebDriver(new URL(URL), caps);84 }85 catch (MalformedURLException e)86 {87 e.printStackTrace();88 }89 }90 else if(browser.equalsIgnoreCase("edge"))91 {92 DesiredCapabilities caps = DesiredCapabilities.edge();93 caps.setCapability("platform", "window 10");94 caps.setCapability("version", "16.16299");95 try96 {97 driver = new RemoteWebDriver(new URL(URL), caps);98 }99 catch (MalformedURLException e)100 {101 e.printStackTrace();102 }103 }104 else105 {106 System.out.println("wrong browser name or empty:"+browser);107 }108 }109 else110 {111 String browser = loadProps.getProperty("browser");112 if(browser.equalsIgnoreCase("chrome")){113 System.setProperty("webdriver.chrome.driver","src\\test\\Resources\\BrowserDriver\\chromedriver77.exe");114 driver = new ChromeDriver();115 }else if(browser.equalsIgnoreCase("firefox")){116 System.setProperty("webdriver.gecko.driver","src\\test\\Resources\\BrowserDriver\\geckodriver.exe");117 driver = new FirefoxDriver();118 }else if(browser.equalsIgnoreCase("edge")){119 System.setProperty("webdriver.edge.driver","src\\test\\Resources\\BrowserDriver\\IEDriverServer.exe");120 driver = new EdgeDriver();121 }122 }123 }124}125 /*If Sauce Lab is true...126 if (SAUCE_LAB) {127 System.out.println("Running in SauceLab......... with browser" + browser);128 if (browser.equalsIgnoreCase("Chrome"))129 {130 MutableCapabilities sauceOptions = new MutableCapabilities();131 ChromeOptions browserOptions = new ChromeOptions();132 browserOptions.setExperimentalOption("w3c", true);133 browserOptions.setCapability("platformName", "Windows 10");134 browserOptions.setCapability("browserVersion", "76.0");135 browserOptions.setCapability("sauce:options", sauceOptions);136 /*DesiredCapabilities caps = DesiredCapabilities.chrome();137 caps.setCapability("platform", "Windows 10");138 caps.setCapability("version", "76.0");*/139 /*try {140 driver = new RemoteWebDriver(new URL(URL), browserOptions);141 } catch (MalformedURLException e) {142 e.printStackTrace();143 }144 }145 else if (browser.equalsIgnoreCase("IE"))146 {147 MutableCapabilities sauceOptions = new MutableCapabilities();148 InternetExplorerOptions browserOptions = new InternetExplorerOptions();149 browserOptions.setCapability("platformName", "Windows 10");150 browserOptions.setCapability("browserVersion", "11.285");151 browserOptions.setCapability("sauce:options", sauceOptions);152 /*DesiredCapabilities caps = DesiredCapabilities.internetExplorer();153 caps.setCapability("platform", "Windows 10");154 caps.setCapability("Version", "11.285");*/155 /*try {156 driver = new RemoteWebDriver(new URL(URL),browserOptions);157 } catch (MalformedURLException e) {158 e.printStackTrace();159 }160 }161 else if (browser.equalsIgnoreCase("FireFox"))162 {163 MutableCapabilities sauceOptions = new MutableCapabilities();164 FirefoxOptions browserOptions = new FirefoxOptions();165 browserOptions.setCapability("platformName", "Windows 10");166 browserOptions.setCapability("browserVersion", "69.0");167 browserOptions.setCapability("sauce:options", sauceOptions);168 /*DesiredCapabilities caps = DesiredCapabilities.firefox();169 caps.setCapability("platform","Windows 10");170 caps.setCapability("version","69.0");171 caps.setCapability("name","Testing on FireFox 69.0");*/172 /*try {173 driver = new RemoteWebDriver(new URL(URL),browserOptions);174 } catch (MalformedURLException e) {175 e.printStackTrace();176 }177 }178 else if (browser.equalsIgnoreCase("safari"))179 {180 MutableCapabilities sauceOptions = new MutableCapabilities();181 SafariOptions browserOptions = new SafariOptions();182 browserOptions.setCapability("platformName", "macOS 10.14");183 browserOptions.setCapability("browserVersion", "12.0");184 browserOptions.setCapability("sauce:options", sauceOptions);185 /*DesiredCapabilities caps = DesiredCapabilities.safari();186 caps.setCapability("platform","macOS 10.14");187 caps.setCapability("version","12.0");*/188 /*try {189 driver = new RemoteWebDriver(new URL(URL),browserOptions);190 } catch (MalformedURLException e) {191 e.printStackTrace();192 }193 }194 else if (browser.equalsIgnoreCase("edge"))195 {196 MutableCapabilities sauceOptions = new MutableCapabilities();197 EdgeOptions browserOptions = new EdgeOptions();198 browserOptions.setCapability("platformName", "Windows 10");199 browserOptions.setCapability("browserVersion", "16.16299");200 browserOptions.setCapability("sauce:options", sauceOptions);201 /*DesiredCapabilities caps = DesiredCapabilities.edge();202 caps.setCapability("platform","Windows 10");203 caps.setCapability("version", "16.16299");*/204 /*try {205 driver = new RemoteWebDriver(new URL(URL),browserOptions);206 } catch (MalformedURLException e) {207 e.printStackTrace();208 }209 }210 else...