How to use getDriver method of com.qaprosoft.carina.core.foundation.webdriver.CarinaDriver class

Best Carina code snippet using com.qaprosoft.carina.core.foundation.webdriver.CarinaDriver.getDriver

Source:IDriverPool.java Github

copy

Full Screen

...62 * Get default driver. If no default driver discovered it will be created.63 * 64 * @return default WebDriver65 */66 default public WebDriver getDriver() {67 return getDriver(DEFAULT);68 }69 /**70 * Get driver by name. If no driver discovered it will be created using71 * default capabilities.72 * 73 * @param name74 * String driver name75 * @return WebDriver76 */77 default public WebDriver getDriver(String name) {78 //customCapabilities.get() return registered custom capabilities or null as earlier79 return getDriver(name, customCapabilities.get(), null);80 }81 /**82 * Get driver by name and DesiredCapabilities.83 * 84 * @param name85 * String driver name86 * @param capabilities87 * DesiredCapabilities capabilities88 * @return WebDriver89 */90 default public WebDriver getDriver(String name, DesiredCapabilities capabilities) {91 return getDriver(name, capabilities, null);92 }93 /**94 * Get driver by name. If no driver discovered it will be created using95 * custom capabilities and selenium server.96 * 97 * @param name98 * String driver name99 * @param capabilities100 * DesiredCapabilities101 * @param seleniumHost102 * String103 * @return WebDriver104 */105 default public WebDriver getDriver(String name, DesiredCapabilities capabilities, String seleniumHost) {106 WebDriver drv = null;107 ConcurrentHashMap<String, CarinaDriver> currentDrivers = getDrivers();108 if (currentDrivers.containsKey(name)) {109 CarinaDriver cdrv = currentDrivers.get(name);110 drv = cdrv.getDriver();111 if (Phase.BEFORE_SUITE.equals(cdrv.getPhase())) {112 POOL_LOGGER.info("Before suite registered driver will be returned.");113 } else {114 POOL_LOGGER.debug(cdrv.getPhase() + " registered driver will be returned.");115 }116 }117 if (drv == null) {118 POOL_LOGGER.debug("Starting new driver as nothing was found in the pool");119 drv = createDriver(name, capabilities, seleniumHost);120 }121 // [VD] do not wrap EventFiringWebDriver here otherwise DriverListener and all logging will be lost!122 return drv;123 }124 /**125 * Get driver by sessionId.126 * 127 * @param sessionId128 * - session id to be used for searching a desired driver129 * 130 * @return default WebDriver131 */132 public static WebDriver getDriver(SessionId sessionId) {133 for (CarinaDriver carinaDriver : driversPool) {134 WebDriver drv = carinaDriver.getDriver();135 if (drv instanceof EventFiringWebDriver) {136 EventFiringWebDriver eventFirDriver = (EventFiringWebDriver) drv;137 drv = eventFirDriver.getWrappedDriver();138 }139 SessionId drvSessionId = ((RemoteWebDriver) drv).getSessionId();140 if (drvSessionId != null) {141 if (sessionId.equals(drvSessionId)) {142 return drv;143 }144 }145 }146 throw new DriverPoolException("Unable to find driver using sessionId artifacts. Returning default one!");147 }148 149 /**150 * Get driver registered to device. If no device discovered null will be returned.151 * 152 * @param device153 * Device154 * @return WebDriver155 */156 default public WebDriver getDriver(Device device) {157 WebDriver drv = null;158 159 for (CarinaDriver carinaDriver : driversPool) {160 if (carinaDriver.getDevice().equals(device)) {161 drv = carinaDriver.getDriver(); 162 }163 }164 165 return drv;166 }167 /**168 * Restart default driver169 * 170 * @return WebDriver171 */172 default public WebDriver restartDriver() {173 return restartDriver(false);174 }175 /**176 * Restart default driver on the same device177 * 178 * @param isSameDevice179 * boolean restart driver on the same device or not180 * @return WebDriver181 */182 default public WebDriver restartDriver(boolean isSameDevice) {183 WebDriver drv = getDriver(DEFAULT);184 Device device = nullDevice;185 DesiredCapabilities caps = new DesiredCapabilities();186 187 boolean keepProxy = false;188 if (isSameDevice) {189 keepProxy = true;190 device = getDevice(drv);191 POOL_LOGGER.debug("Added udid: " + device.getUdid() + " to capabilities for restartDriver on the same device.");192 caps.setCapability("udid", device.getUdid());193 }194 POOL_LOGGER.debug("before restartDriver: " + driversPool);195 for (CarinaDriver carinaDriver : driversPool) {196 if (carinaDriver.getDriver().equals(drv)) {197 quitDriver(carinaDriver, keepProxy);198 // [VD] don't remove break or refactor moving removal out of "for" cycle199 driversPool.remove(carinaDriver);200 break;201 }202 }203 POOL_LOGGER.debug("after restartDriver: " + driversPool);204 return createDriver(DEFAULT, caps, null);205 }206 /**207 * Quit default driver208 */209 default public void quitDriver() {210 quitDriver(DEFAULT);211 }212 /**213 * Quit driver by name214 * 215 * @param name216 * String driver name217 */218 default public void quitDriver(String name) {219 WebDriver drv = null;220 CarinaDriver carinaDrv = null;221 Long threadId = Thread.currentThread().getId();222 POOL_LOGGER.debug("before quitDriver: " + driversPool);223 for (CarinaDriver carinaDriver : driversPool) {224 if ((Phase.BEFORE_SUITE.equals(carinaDriver.getPhase()) && name.equals(carinaDriver.getName()))225 || (threadId.equals(carinaDriver.getThreadId()) && name.equals(carinaDriver.getName()))) {226 drv = carinaDriver.getDriver();227 carinaDrv = carinaDriver;228 break;229 }230 }231 if (drv == null || carinaDrv == null) {232 throw new RuntimeException("Unable to find driver '" + name + "'!");233 }234 235 quitDriver(carinaDrv, false);236 driversPool.remove(carinaDrv);237 POOL_LOGGER.debug("after quitDriver: " + driversPool);238 }239 /**240 * Quit current drivers by phase(s). "Current" means assigned to the current test/thread.241 * 242 * @param phase243 * Comma separated driver phases to quit244 */245 default public void quitDrivers(Phase...phase) {246 List<Phase> phases = Arrays.asList(phase);247 Set<CarinaDriver> drivers4Remove = new HashSet<CarinaDriver>();248 Long threadId = Thread.currentThread().getId();249 for (CarinaDriver carinaDriver : driversPool) {250 if ((phases.contains(carinaDriver.getPhase()) && threadId.equals(carinaDriver.getThreadId()))251 || phases.contains(Phase.ALL)) {252 quitDriver(carinaDriver, false);253 drivers4Remove.add(carinaDriver);254 }255 }256 driversPool.removeAll(drivers4Remove);257 removeCapabilities();258 // don't use modern removeIf as it uses iterator!259 // driversPool.removeIf(carinaDriver -> phase.equals(carinaDriver.getPhase()) && threadId.equals(carinaDriver.getThreadId()));260 }261 262 /**263 * Set custom capabilities.264 * 265 * @param caps capabilities266 */267 default public void setCapabilities(DesiredCapabilities caps) {268 customCapabilities.set(caps);269 }270 271 /**272 * Remove custom capabilities.273 */274 default public void removeCapabilities() {275 customCapabilities.remove();276 } 277 278 private void quitDriver(CarinaDriver carinaDriver, boolean keepProxyDuring) {279 try {280 carinaDriver.getDevice().disconnectRemote();281 282 // castDriver to disable DriverListener operations on quit283 WebDriver drv = castDriver(carinaDriver.getDriver());284 POOL_LOGGER.debug("start driver quit: " + carinaDriver.getName());285 286 Future<?> future = Executors.newSingleThreadExecutor().submit(new Callable<Void>() {287 public Void call() throws Exception {288 if (Configuration.getBoolean(Parameter.CHROME_CLOSURE)) {289 // workaround to not cleaned chrome profiles on hard drive290 POOL_LOGGER.debug("Starting drv.close()");291 drv.close();292 POOL_LOGGER.debug("Finished drv.close()");293 }294 POOL_LOGGER.debug("Starting drv.quit()");295 drv.quit();296 POOL_LOGGER.debug("Finished drv.quit()");297 return null;298 }299 });300 301 // default timeout for driver quit 1/2 of explicit302 long timeout = Configuration.getInt(Parameter.EXPLICIT_TIMEOUT) / 2;303 try {304 future.get(timeout, TimeUnit.SECONDS);305 } catch (InterruptedException e) {306 POOL_LOGGER.error("InterruptedException: Unable to quit driver!", e);307 Thread.currentThread().interrupt();308 } catch (ExecutionException e) {309 if (e.getMessage() != null && e.getMessage().contains("not found in active sessions")) {310 POOL_LOGGER.warn("Skip driver quit for already disconnected session!");311 } else {312 POOL_LOGGER.error("ExecutionException: Unable to quit driver!", e);313 }314 } catch (java.util.concurrent.TimeoutException e) {315 POOL_LOGGER.error("Unable to quit driver for " + timeout + "sec!", e);316 }317 } catch (WebDriverException e) {318 POOL_LOGGER.debug("Error message detected during driver quit!", e);319 // do nothing320 } catch (Exception e) {321 POOL_LOGGER.error("Error discovered during driver quit!", e);322 } finally {323 POOL_LOGGER.debug("finished driver quit: " + carinaDriver.getName());324 if (!keepProxyDuring) {325 ProxyPool.stopProxy();326 }327 }328 }329 330 private WebDriver castDriver(WebDriver drv) {331 if (drv instanceof EventFiringWebDriver) {332 drv = ((EventFiringWebDriver) drv).getWrappedDriver();333 }334 return drv; 335 } 336 337 /**338 * Create driver with custom capabilities339 * 340 * @param name341 * String driver name342 * @param capabilities343 * DesiredCapabilities344 * @param seleniumHost345 * String346 * @return WebDriver347 */348 private WebDriver createDriver(String name, DesiredCapabilities capabilities, String seleniumHost) {349 int count = 0;350 WebDriver drv = null;351 Device device = nullDevice;352 // 1 - is default run without retry353 int maxCount = Configuration.getInt(Parameter.INIT_RETRY_COUNT) + 1;354 while (drv == null && count++ < maxCount) {355 try {356 POOL_LOGGER.debug("initDriver start...");357 358 Long threadId = Thread.currentThread().getId();359 ConcurrentHashMap<String, CarinaDriver> currentDrivers = getDrivers();360 int maxDriverCount = Configuration.getInt(Parameter.MAX_DRIVER_COUNT);361 if (currentDrivers.size() == maxDriverCount) {362 Assert.fail("Unable to create new driver as you reached max number of drivers per thread: " + maxDriverCount + "!" +363 " Override max_driver_count to allow more drivers per test!");364 }365 // [VD] pay attention that similar piece of code is copied into the DriverPoolTest as registerDriver method!366 if (currentDrivers.containsKey(name)) {367 // [VD] moved containsKey verification before the driver start368 Assert.fail("Driver '" + name + "' is already registered for thread: " + threadId);369 }370 371 drv = DriverFactory.create(name, capabilities, seleniumHost);372 373 if (currentDevice.get() != null) {374 device = currentDevice.get();375 }376 377 CarinaDriver carinaDriver = new CarinaDriver(name, drv, device, TestPhase.getActivePhase(), threadId);378 driversPool.add(carinaDriver);379 POOL_LOGGER.debug("initDriver finish...");380 381 if (Configuration.getBoolean(Parameter.BROWSERMOB_PROXY)) {382 if (!device.isNull()) {383 int proxyPort;384 try {385 proxyPort = Integer.parseInt(device.getProxyPort());386 } catch (NumberFormatException e) {387 // use default from _config.properties. Use-case for388 // iOS devices which doesn't have proxy_port as part389 // of capabilities390 proxyPort = ProxyPool.getProxyPortFromConfig();391 }392 ProxyPool.startProxy(proxyPort);393 }394 }395 } catch (Exception e) {396 device.disconnectRemote();397 //TODO: [VD] think about excluding device from pool for explicit reasons like out of space etc398 // but initially try to implement it on selenium-hub level399 String msg = String.format("Driver initialization '%s' FAILED! Retry %d of %d time - %s", name, count,400 maxCount, e.getMessage());401 402 if (count == maxCount) {403 throw e;404 } else {405 // do not provide huge stacktrace as more retries exists. Only latest will generate full error + stacktrace406 POOL_LOGGER.error(msg); 407 }408 CommonUtils.pause(Configuration.getInt(Parameter.INIT_RETRY_INTERVAL));409 }410 }411 412 if (drv == null) {413 throw new RuntimeException("Undefined exception detected! Analyze above logs for details.");414 }415 return drv;416 }417 /**418 * Verify if driver is registered in the DriverPool419 * 420 * @param name421 * String driver name422 *423 * @return boolean424 */425 default boolean isDriverRegistered(String name) {426 return getDrivers().containsKey(name);427 }428 /**429 * Return all drivers registered in the DriverPool for this thread including430 * on Before Suite/Class/Method stages431 * 432 * @return ConcurrentHashMap of driver names and Carina WebDrivers433 * 434 */435 default ConcurrentHashMap<String, CarinaDriver> getDrivers() {436 Long threadId = Thread.currentThread().getId();437 ConcurrentHashMap<String, CarinaDriver> currentDrivers = new ConcurrentHashMap<String, CarinaDriver>();438 for (CarinaDriver carinaDriver : driversPool) {439 if (Phase.BEFORE_SUITE.equals(carinaDriver.getPhase())) {440 currentDrivers.put(carinaDriver.getName(), carinaDriver);441 } else if (threadId.equals(carinaDriver.getThreadId())) {442 currentDrivers.put(carinaDriver.getName(), carinaDriver);443 }444 }445 return currentDrivers;446 }447 // ------------------------ DEVICE POOL METHODS -----------------------448 /**449 * Get device registered to default driver. If no default driver discovered nullDevice will be returned.450 * 451 * @return default Device452 */453 default public Device getDevice() {454 return getDevice(DEFAULT);455 }456 /**457 * Get device registered to named driver. If no driver discovered nullDevice will be returned.458 * 459 * @param name460 * String driver name461 * @return Device462 */463 default public Device getDevice(String name) {464 if (isDriverRegistered(name)) {465 return getDrivers().get(name).getDevice();466 } else {467 return nullDevice;468 }469 470 }471 472 /**473 * Get device registered to driver. If no driver discovered nullDevice will be returned.474 * 475 * @param drv476 * WebDriver477 * @return Device478 */479 default public Device getDevice(WebDriver drv) {480 Device device = nullDevice;481 482 for (CarinaDriver carinaDriver : driversPool) {483 if (carinaDriver.getDriver().equals(drv)) {484 device = carinaDriver.getDevice();485 break;486 }487 }488 489 return device;490 }491 /**492 * Register device information for current thread by MobileFactory and clear SysLog for Android only493 * 494 * @param device495 * String Device device496 * 497 * @return Device device...

Full Screen

Full Screen

Source:DriverPoolTest.java Github

copy

Full Screen

...54 this.mockDriverSuite = mock(WebDriver.class);55 registerDriver(mockDriverSuite, BEFORE_SUITE_DRIVER_NAME);56 Assert.assertEquals(driversPool.size(), 1,57 "Driver pool is empty after before suite driver has been registered");58 Assert.assertEquals(getDriver(BEFORE_SUITE_DRIVER_NAME), mockDriverSuite, "Incorrect driver has been returned");59 changeBeforeSuiteDriverThread();60 this.mockDriverDefault = mock(WebDriver.class);61 this.mockDriverCustom1 = mock(WebDriver.class);62 this.mockDriverCustom2 = mock(WebDriver.class);63 }64 @Test()65 public void beforeClassGetSuiteDriver() {66 TestPhase.setActivePhase(Phase.BEFORE_CLASS);67 Assert.assertEquals(getDriver(BEFORE_SUITE_DRIVER_NAME), mockDriverSuite, "Incorrect driver has been returned");68 Assert.assertTrue(getDrivers().containsKey(BEFORE_SUITE_DRIVER_NAME), "Before suite driver has not been returned by getDrivers()");69 }70 @Test(dependsOnMethods = { "beforeClassGetSuiteDriver" })71 public void beforeMethodGetSuiteDriver() {72 TestPhase.setActivePhase(Phase.BEFORE_METHOD);73 Assert.assertEquals(getDriver(BEFORE_SUITE_DRIVER_NAME), mockDriverSuite, "Incorrect driver has been returned");74 }75 @Test(dependsOnMethods = { "beforeMethodGetSuiteDriver" })76 public void methodGetSuiteDriver() {77 TestPhase.setActivePhase(Phase.METHOD);78 Assert.assertEquals(getDriver(BEFORE_SUITE_DRIVER_NAME), mockDriverSuite, "Incorrect driver has been returned");79 }80 @Test(dependsOnMethods = { "methodGetSuiteDriver" })81 public void quiteSuiteDriver() {82 deregisterDriver(mockDriverSuite);83 Assert.assertEquals(getDrivers().size(), 0, "Number of registered driver is not valid!");84 }85 @Test(dependsOnMethods = { "quiteSuiteDriver" })86 public void registerDefaultDriver() {87 R.CONFIG.put("max_driver_count", "2");88 registerDriver(mockDriverDefault, IDriverPool.DEFAULT);89 Assert.assertEquals(getDrivers().size(), 1, "Number of registered driver is not valid!");90 Assert.assertTrue(isDriverRegistered(IDriverPool.DEFAULT), "Default driver is not registered!");91 Assert.assertEquals(getDriver(), mockDriverDefault, "Returned driver is not the same as registered!");92 }93 94 @Test(dependsOnMethods = "registerDefaultDriver", expectedExceptions = {95 AssertionError.class }, expectedExceptionsMessageRegExp = "Driver 'default' is already registered for thread: 1")96 public void registerTwiceDefaultDriver() {97 registerDriver(mockDriverDefault, IDriverPool.DEFAULT);98 }99 @Test(dependsOnMethods = { "registerDefaultDriver", "registerTwiceDefaultDriver" })100 public void deregisterDefaultDriver() {101 quitDriver();102 deregisterDriver(mockDriverDefault);103 Assert.assertFalse(isDriverRegistered(IDriverPool.DEFAULT), "Default driver is not deregistered!");104 LOGGER.info("drivers count: " + getDrivers().size());105 Assert.assertEquals(getDrivers().size(), 0, "Number of registered driver is not valid!");106 }107 @Test(dependsOnMethods = { "deregisterDefaultDriver" })108 public void quitDriverByPhase() {109 TestPhase.setActivePhase(Phase.BEFORE_METHOD);110 registerDriver(mockDriverDefault, IDriverPool.DEFAULT);111 Assert.assertEquals(getDrivers().size(), 1, "Number of registered driver is not valid!");112 quitDrivers(Phase.BEFORE_METHOD);113 Assert.assertEquals(getDrivers().size(), 0, "Number of registered driver is not valid!");114 }115 116 @Test(dependsOnMethods = { "quitDriverByPhase" })117 public void quitDefaultDriver() {118 TestPhase.setActivePhase(Phase.METHOD);119 registerDriver(mockDriverDefault, IDriverPool.DEFAULT);120 Assert.assertEquals(getDrivers().size(), 1, "Number of registered driver is not valid!");121 quitDriver();122 Assert.assertEquals(getDrivers().size(), 0, "Number of registered driver is not valid!");123 }124 125 @Test(dependsOnMethods = { "quitDefaultDriver" })126 public void quitDriverByName() {127 TestPhase.setActivePhase(Phase.METHOD);128 registerDriver(mockDriverDefault, IDriverPool.DEFAULT);129 Assert.assertEquals(1, getDrivers().size(), "Number of registered driver is not valid!");130 quitDriver(IDriverPool.DEFAULT);131 Assert.assertEquals(0, getDrivers().size(), "Number of registered driver is not valid!");132 }133 134 @Test(dependsOnMethods = { "quitDriverByName" })135 public void registerCustom1Driver() {136 registerDriver(mockDriverCustom1, CUSTOM1);137 Assert.assertTrue(isDriverRegistered(CUSTOM1), "Custom1 driver is not registered!");138 Assert.assertEquals(getDrivers().size(), 1, "Number of registered driver is not valid!");139 }140 @Test(dependsOnMethods = "registerCustom1Driver")141 public void getCustom1Driver() {142 Assert.assertEquals(getDriver(CUSTOM1), mockDriverCustom1, "Returned driver is not the same as registered!");143 }144 @Test(dependsOnMethods = "getCustom1Driver", expectedExceptions = {145 AssertionError.class }, expectedExceptionsMessageRegExp = "Unable to register driver as you reached max number of drivers per thread: 2")146 public void reachMaxDriverCountTest() {147 registerDriver(mockDriverDefault, IDriverPool.DEFAULT);148 registerDriver(mockDriverCustom2, CUSTOM2);149 Assert.assertFalse(isDriverRegistered(CUSTOM2),150 CUSTOM2 + " driver is registered in spite of the max_drivercount=2");151 Assert.assertEquals(getDrivers().size(), 2, "Number of registered driver is not valid!");152 }153 @Test(dependsOnMethods = { "reachMaxDriverCountTest" })154 public void deregisterCustom1Driver() {155 deregisterDriver(mockDriverCustom1);156 Assert.assertFalse(isDriverRegistered(CUSTOM1), CUSTOM1 + " driver is not deregistered!");157 Assert.assertEquals(getDrivers().size(), 1, "Number of registered driver is not valid!");158 deregisterDriver(mockDriverDefault);159 Assert.assertEquals(getDrivers().size(), 0, "Number of registered driver is not valid!");160 }161 @Test(dependsOnMethods = { "deregisterCustom1Driver" })162 public void deregisterAllDrivers() {163 registerDriver(mockDriverDefault, IDriverPool.DEFAULT);164 Assert.assertEquals(getDrivers().size(), 1, "Number of registered driver is not valid!");165 registerDriver(mockDriverCustom1, CUSTOM1);166 Assert.assertEquals(getDrivers().size(), 2, "Number of registered driver is not valid!");167 168 quitDrivers(Phase.ALL);169 Assert.assertEquals(getDrivers().size(), 0, "Number of registered driver is not valid!");170 }171 172 @Test(dependsOnMethods = { "deregisterAllDrivers" })173 public void registerDriverWithDevice() {174 WebDriver deviceDriver = mock(WebDriver.class);175 Device device = new Device("name", "type", "os", "osVersion", "udid", "remoteUrl", "vnc", "proxyPort");176 registerDriver(deviceDriver, IDriverPool.DEFAULT, device);177 Assert.assertEquals(getDrivers().size(), 1, "Number of registered driver is not valid!");178 179 Assert.assertEquals(getDriver(), deviceDriver, "Returned driver is not the same as registered!");180 Assert.assertEquals(getDevice(), device, "Returned device is not the same as registered!");181 quitDrivers(Phase.ALL);182 }183 184 private void changeBeforeSuiteDriverThread() {185 for (CarinaDriver cDriver : driversPool) {186 if (Phase.BEFORE_SUITE.equals(cDriver.getPhase())) {187 long newThreadID = cDriver.getThreadId() + 1;188 cDriver.setThreadId(newThreadID);189 }190 }191 }192 /**193 * Register driver in the DriverPool194 * 195 * @param driver196 * WebDriver197 * @param name198 * String driver name199 * 200 */201 private void registerDriver(WebDriver driver, String name) {202 registerDriver(driver, name, IDriverPool.getNullDevice());203 }204 /**205 * Register driver in the DriverPool with device206 * 207 * @param driver208 * WebDriver209 * @param name210 * String driver name211 * @param device212 * Device213 * 214 */215 private void registerDriver(WebDriver driver, String name, Device device) {216 Long threadId = Thread.currentThread().getId();217 ConcurrentHashMap<String, CarinaDriver> currentDrivers = getDrivers();218 int maxDriverCount = Configuration.getInt(Parameter.MAX_DRIVER_COUNT);219 if (currentDrivers.size() == maxDriverCount) {220 Assert.fail("Unable to register driver as you reached max number of drivers per thread: " + maxDriverCount);221 }222 if (currentDrivers.containsKey(name)) {223 Assert.fail("Driver '" + name + "' is already registered for thread: " + threadId);224 }225 // new 6.0 approach to manipulate drivers via regular Set226 CarinaDriver carinaDriver = new CarinaDriver(name, driver, device, TestPhase.getActivePhase(), threadId);227 driversPool.add(carinaDriver);228 }229 /**230 * Deregister driver from the DriverPool231 * 232 * @param drv233 * WebDriver driver234 * 235 */236 private void deregisterDriver(WebDriver drv) {237 Iterator<CarinaDriver> iter = driversPool.iterator();238 while (iter.hasNext()) {239 CarinaDriver carinaDriver = iter.next();240 if (carinaDriver.getDriver().equals(drv)) {241 LOGGER.info("removing driver " + carinaDriver.getName());242 iter.remove();243 }244 }245 }246}...

Full Screen

Full Screen

Source:CarinaDriver.java Github

copy

Full Screen

...31 this.device = device;32 this.phase = phase;33 this.threadId = threadId;34 }35 public WebDriver getDriver() {36 return driver;37 }38 public Device getDevice() {39 return device;40 }41 public String getName() {42 return name;43 }44 public long getThreadId() {45 return threadId;46 }47 public Phase getPhase() {48 return phase;49 }...

Full Screen

Full Screen

getDriver

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.CarinaDriver;2public class 1 {3public static void main(String[] args) {4CarinaDriver driver = CarinaDriver.getDriver();5}6}7import com.qaprosoft.carina.core.foundation.webdriver.DriverHelper;8public class 2 {9public static void main(String[] args) {10DriverHelper driver = DriverHelper.getDriver();11}12}13import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;14public class 3 {15public static void main(String[] args) {16DriverPool driver = DriverPool.getDriver();17}18}19import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;20public class 4 {21public static void main(String[] args) {22IDriverPool driver = IDriverPool.getDriver();23}24}25import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.android.AndroidDriverPool;26public class 5 {27public static void main(String[] args) {28AndroidDriverPool driver = AndroidDriverPool.getDriver();29}30}31import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.desktop.DesktopDriverPool;32public class 6 {33public static void main(String[] args) {34DesktopDriverPool driver = DesktopDriverPool.getDriver();35}36}37import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.ios.IOSDriverPool;38public class 7 {39public static void main(String[] args) {40IOSDriverPool driver = IOSDriverPool.getDriver();41}42}

Full Screen

Full Screen

getDriver

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.webdriver;2import org.openqa.selenium.WebDriver;3import com.qaprosoft.carina.core.foundation.webdriver.device.DevicePool;4public class CarinaDriver {5 public static WebDriver getDriver() {6 return DevicePool.getDevice().getDriver();7 }8}9package com.qaprosoft.carina.core.foundation.webdriver;10import org.openqa.selenium.WebDriver;11public class DevicePool {12 public static Device getDevice() {13 return new Device();14 }15}16package com.qaprosoft.carina.core.foundation.webdriver;17import org.openqa.selenium.WebDriver;18public class Device {19 public WebDriver getDriver() {20 return null;21 }22}

Full Screen

Full Screen

getDriver

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.webdriver;2import org.openqa.selenium.WebDriver;3import org.testng.annotations.Test;4public class CarinaDriverTest {5public void testGetDriver() {6 WebDriver driver = CarinaDriver.getDriver();7 System.out.println("driver: " + driver);8}9}10package com.qaprosoft.carina.core.foundation.webdriver.core.factory.impl;11import org.openqa.selenium.WebDriver;12import org.testng.annotations.Test;13import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;14public class DefaultFactoryTest {15public void testGetDriver() {16 WebDriver driver = DriverPool.getDriver();17 System.out.println("driver: " + driver);18}19}20package com.qaprosoft.carina.core.foundation.webdriver.core.factory.impl;21import org.openqa.selenium.WebDriver;22import org.testng.annotations.Test;23import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;24public class MobileFactoryTest {25public void testGetDriver() {26 WebDriver driver = DriverPool.getDriver();27 System.out.println("driver: " + driver);28}29}30package com.qaprosoft.carina.core.foundation.webdriver.core.factory.impl;31import org.openqa.selenium.WebDriver;32import org.testng.annotations.Test;33import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;34public class DesktopFactoryTest {35public void testGetDriver() {36 WebDriver driver = DriverPool.getDriver();37 System.out.println("driver: " + driver);38}39}40package com.qaprosoft.carina.core.foundation.webdriver.core.factory.impl;41import org.openqa.selenium.WebDriver;42import org.testng.annotations.Test;43import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;44public class DesktopFactoryTest {45public void testGetDriver() {46 WebDriver driver = DriverPool.getDriver();47 System.out.println("driver: " + driver);48}49}

Full Screen

Full Screen

getDriver

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.CarinaDriver;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.support.ui.WebDriverWait;4import org.testng.Assert;5import org.testng.annotations.Test;6public class CarinaDriverTest {7 public void testGetDriver() {8 WebDriver driver = CarinaDriver.getDriver();9 Assert.assertNotNull(driver);10 WebDriverWait wait = new WebDriverWait(driver, 10);11 Assert.assertNotNull(wait);12 }13}14import com.qaprosoft.carina.core.foundation.webdriver.DriverHelper;15import org.openqa.selenium.WebDriver;16import org.openqa.selenium.support.ui.WebDriverWait;17import org.testng.Assert;18import org.testng.annotations.Test;19public class DriverHelperTest {20 public void testGetDriver() {21 WebDriver driver = DriverHelper.getDriver();22 Assert.assertNotNull(driver);23 WebDriverWait wait = new WebDriverWait(driver, 10);24 Assert.assertNotNull(wait);25 }26}27import com.qaprosoft.carina.core.foundation.webdriver.DriverFactory;28import org.openqa.selenium.WebDriver;29import org.openqa.selenium.support.ui.WebDriverWait;30import org.testng.Assert;31import org.testng.annotations.Test;32public class DriverFactoryTest {33 public void testGetDriver() {34 WebDriver driver = DriverFactory.getDriver();35 Assert.assertNotNull(driver);36 WebDriverWait wait = new WebDriverWait(driver, 10);37 Assert.assertNotNull(wait);38 }39}40import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;41import org.openqa.selenium.WebDriver;42import org.openqa.selenium.support.ui.WebDriverWait;43import org.testng.Assert;44import org.testng.annotations.Test;45public class IDriverPoolTest {46 public void testGetDriver() {47 WebDriver driver = IDriverPool.getDriver();48 Assert.assertNotNull(driver);49 WebDriverWait wait = new WebDriverWait(driver, 10);50 Assert.assertNotNull(wait);51 }52}53import com.qaprosoft

Full Screen

Full Screen

getDriver

Using AI Code Generation

copy

Full Screen

1public class TestClass {2 public static void main(String[] args) {3 CarinaDriver driver = CarinaDriver.getDriver();4 }5}6public class TestClass {7 public static void main(String[] args) {8 CarinaDriver driver = DriverHelper.getDriver();9 }10}11public class TestClass {12 public static void main(String[] args) {13 CarinaDriver driver = DriverHelper.getDriver();14 }15}16public class TestClass {17 public static void main(String[] args) {18 CarinaDriver driver = DriverHelper.getDriver();19 }20}21public class TestClass {22 public static void main(String[] args) {23 CarinaDriver driver = DriverHelper.getDriver();24 }25}26public class TestClass {27 public static void main(String[] args) {28 CarinaDriver driver = DriverHelper.getDriver();29 }30}31public class TestClass {32 public static void main(String[] args) {33 CarinaDriver driver = DriverHelper.getDriver();34 }35}36public class TestClass {37 public static void main(String[] args) {38 CarinaDriver driver = DriverHelper.getDriver();39 }40}41public class TestClass {42 public static void main(String[] args) {43 CarinaDriver driver = DriverHelper.getDriver();44 }45}46public class TestClass {47 public static void main(String[] args) {48 CarinaDriver driver = DriverHelper.getDriver();49 }50}

Full Screen

Full Screen

getDriver

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.CarinaDriver;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.chrome.ChromeDriver;4import org.testng.annotations.Test;5public class Test1 {6 public void test1() {7 WebDriver driver = CarinaDriver.getDriver();8 }9}10import com.qaprosoft.carina.core.foundation.webdriver.DriverHelper;11import org.openqa.selenium.WebDriver;12import org.openqa.selenium.chrome.ChromeDriver;13import org.testng.annotations.Test;14public class Test2 {15 public void test2() {16 WebDriver driver = DriverHelper.getDriver();17 }18}19import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;20import org.openqa.selenium.WebDriver;21import org.openqa.selenium.chrome.ChromeDriver;22import org.testng.annotations.Test;23public class Test3 {24 public void test3() {25 WebDriver driver = DriverPool.getDriver();26 }27}28import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;29import org.openqa.selenium.WebDriver;30import org.openqa.selenium.chrome.ChromeDriver;31import org.testng.annotations.Test;32public class Test4 {33 public void test4() {34 WebDriver driver = DriverPool.getDriver();35 }36}37import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;38import org.openqa.selenium.WebDriver;39import org.openqa.selenium.chrome.ChromeDriver;40import org.testng.annotations.Test;41public class Test5 {42 public void test5() {43 WebDriver driver = DriverPool.getDriver();44 }45}

Full Screen

Full Screen

getDriver

Using AI Code Generation

copy

Full Screen

1public class CarinaDriverDemo {2 public static void main(String[] args) {3 System.setProperty("config", "src/main/resources/config.properties");4 System.setProperty("suite", "src/main/resources/suite.xml");5 CarinaDriver driver = CarinaDriver.getDriver();6 driver.quit();7 }8}9public class DriverHelperDemo {10 public static void main(String[] args) {11 System.setProperty("config", "src/main/resources/config.properties");12 System.setProperty("suite", "src/main/resources/suite.xml");13 DriverHelper driverHelper = new DriverHelper();14 CarinaDriver driver = driverHelper.getDriver();15 driver.quit();16 }17}18public class DriverPoolDemo {19 public static void main(String[] args) {20 System.setProperty("config", "src/main/resources/config.properties");21 System.setProperty("suite", "src/main/resources/suite.xml");22 CarinaDriver driver = DriverPool.getDriver();23 driver.quit();24 }25}26public class DriverPoolDemo {27 public static void main(String[] args) {28 System.setProperty("config", "src/main/resources/config.properties");29 System.setProperty("suite", "src/main/resources/suite.xml");30 CarinaDriver driver = DriverPool.getDriver();31 driver.quit();32 }33}34public class DriverPoolDemo {35 public static void main(String[] args) {36 System.setProperty("config", "src/main/resources/config.properties");37 System.setProperty("suite", "src/main/resources/suite.xml");38 CarinaDriver driver = DriverPool.getDriver();39 driver.quit();40 }41}

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Carina automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful