Best Carina code snippet using com.qaprosoft.carina.core.foundation.webdriver.core.factory.DriverFactory.create
Source:DriverFactory.java
...40 public static final String HTML_UNIT = "htmlunit";41 protected static final Logger LOGGER = Logger.getLogger(DriverFactory.class);42 private static final Device nullDevice = new Device();43 @SuppressWarnings("rawtypes")44 public static WebDriver create(String testName, DesiredCapabilities capabilities, String selenium_host) {45 RemoteWebDriver driver = null;46 try {47 if (capabilities.getCapability("automationName") == null)48 driver = new RemoteWebDriver(new URL(selenium_host), capabilities);49 else {50 String platform;51 if (capabilities.getCapability("platform") != null) {52 platform = capabilities.getCapability("platform").toString();53 } else if (capabilities.getCapability("platformName") != null) {54 platform = capabilities.getCapability("platformName").toString();55 } else {56 throw new RuntimeException("Unable to identify platform type using platform and platformName capabilities for test: " + testName);57 }58 if (platform.toLowerCase().equals("android")) {59 driver = new AndroidDriver(new URL(selenium_host), capabilities);60 } else if (platform.toLowerCase().equals("ios")) {61 driver = new IOSDriver(new URL(selenium_host), capabilities);62 } else {63 throw new RuntimeException("Undefined platform type for mobile driver test: " + testName);64 }65 }66 } catch (Exception e) {67 LOGGER.error("Unable to initialize extra driver!\r\n" + e.getMessage());68 }69 70 if (driver == null) {71 LOGGER.error("Page isn't created. There is no any initialized driver for thread: " + Thread.currentThread().getId());72 DevicePool.removeDevice();73 throw new RuntimeException("Page isn't created. Driver isn't initialized.");74 }75 return driver;76 }77 /**78 * Creates driver instance for specified test.79 *80 * @param testName in which driver will be used81 * @return RemoteWebDriver instance82 */83 public static WebDriver create(String testName) {84 return create(testName, nullDevice);85 }86 public static WebDriver create(String testName, Device device) {87 LOGGER.debug("DriverFactory start...");88 AbstractFactory factory;89 String driverType = Configuration.get(Parameter.DRIVER_TYPE);90 if (driverType.equalsIgnoreCase(SpecialKeywords.DESKTOP)) {91 factory = new DesktopFactory();92 } else if (driverType.equalsIgnoreCase(SpecialKeywords.MOBILE)93 || driverType.equalsIgnoreCase(SpecialKeywords.MOBILE_POOL)94 || driverType.equalsIgnoreCase(SpecialKeywords.MOBILE_GRID)) {95 factory = new MobileFactory();96 } else {97 throw new RuntimeException("Unsupported driver_type: " + driverType + "!");98 }99 WebDriver drv = factory.create(testName, device);100 LOGGER.debug("DriverFactory finish...");101 return drv;102 }103 public static String getBrowserName(WebDriver driver) {104 Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();105 return cap.getBrowserName().toString();106 }107 public static String getBrowserVersion(WebDriver driver) {108 Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();109 return cap.getVersion().toString();110 }111}...
create
Using AI Code Generation
1DriverFactory.createInstance("chrome");2DriverFactory.createInstance("firefox");3DriverFactory.createInstance("ie");4DriverFactory.createInstance("safari");5DriverFactory.createInstance("edge");6DriverFactory.createInstance("phantomjs");7DriverFactory.createInstance("android");8DriverFactory.createInstance("ios");9DriverFactory.createInstance("appium");10DriverFactory.createInstance("chrome", "capabilities");11DriverFactory.createInstance("firefox", "capabilities");12DriverFactory.createInstance("ie", "capabilities");13DriverFactory.createInstance("safari", "capabilities");14DriverFactory.createInstance("edge", "capabilities");15DriverFactory.createInstance("phantomjs", "capabilities");16DriverFactory.createInstance("android", "capabilities");17DriverFactory.createInstance("ios
create
Using AI Code Generation
1DriverFactory.createDriver("chrome");2DriverFactory.getDriver().quit();3DriverFactory.createDriver("chrome");4DriverFactory.getDriver().quit();5DriverFactory.createDriver("chrome");6DriverFactory.getDriver().quit();7DriverFactory.createDriver("chrome");8DriverFactory.getDriver().quit();9DriverFactory.createDriver("chrome");10DriverFactory.getDriver().quit();11DriverFactory.createDriver("chrome");12DriverFactory.getDriver().quit();13DriverFactory.createDriver("chrome");14DriverFactory.getDriver().quit();15DriverFactory.createDriver("chrome");16DriverFactory.getDriver().quit();17DriverFactory.createDriver("chrome");18DriverFactory.getDriver().quit();19DriverFactory.createDriver("chrome");20DriverFactory.getDriver().quit();21DriverFactory.createDriver("chrome");
create
Using AI Code Generation
1DriverFactory.createInstance("Android", "Android", "Android Emulator");2DriverFactory.createInstance("Android", "Android", "Android Emulator");3DriverFactory.createInstance("Android", "Android", "Android Emulator");4DriverFactory.createInstance("Android", "Android", "Android Emulator");5DriverFactory.createInstance("Android", "Android", "Android Emulator");6DriverFactory.createInstance("Android", "Android", "Android Emulator");7DriverFactory.createInstance("Android", "Android", "Android Emulator");8DriverFactory.createInstance("Android", "Android", "Android Emulator");9DriverFactory.createInstance("Android", "Android", "Android Emulator");10DriverFactory.createInstance("Android", "Android", "Android Emulator");11DriverFactory.createInstance("Android", "Android", "Android Emulator");12DriverFactory.createInstance("Android", "Android", "Android Emulator");13DriverFactory.createInstance("Android", "Android", "Android Emulator");14DriverFactory.createInstance("Android", "Android", "Android Emulator");
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!