How to use quitDriver method of com.qaprosoft.carina.core.foundation.webdriver.IDriverPool class

Best Carina code snippet using com.qaprosoft.carina.core.foundation.webdriver.IDriverPool.quitDriver

Source:IDriverPool.java Github

copy

Full Screen

...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()");...

Full Screen

Full Screen

Source:DriverPoolTest.java Github

copy

Full Screen

...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 driver...

Full Screen

Full Screen

quitDriver

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;2import com.qaprosoft.carina.core.foundation.webdriver.Screenshot;3import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;4import com.qaprosoft.carina.core.foundation.webdriver.decorator.PageOpeningStrategy;5import com.qaprosoft.carina.core.foundation.webdriver.decorator.PageOpeningStrategy.PageOpeningStrategyType;6import com.qaprosoft.carina.core.foundation.webdriver.decorator.PageOpeningStrategyFactory;7import com.qaprosoft.carina.core.foundation.webdriver.locator.ExtendedLocator;8import com.qaprosoft.carina.core.foundation.webdriver.locator.LocatorType;9import com.qaprosoft.carina.core.foundation.webdriver.locator.LocatorUtil;10import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringDecorator;11import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringDecoratorFactory;12import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringDecoratorType;13import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileEventFiringDecorator;14import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileEventFiringDecoratorFactory;15import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileEventFiringDecoratorType;16import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileEventFiringDecoratorType;17import com.qaprosoft.carina.core.foundation.webdriver.locator.ExtendedLocator;18import com.qaprosoft.carina.core.foundation.webdriver.locator.LocatorType;19import com.qaprosoft.carina.core.foundation.webdriver.locator.LocatorUtil;20import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringDecorator;21import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringDecoratorFactory;22import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringDecoratorType;23import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileEventFiringDecorator;24import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileEventFiringDecoratorFactory;25import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileEventFiringDecoratorType;26import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileEventFiringDecoratorType;27import com.qaprosoft.carina.core.foundation.webdriver.locator.ExtendedLocator;28import com.qaprosoft.carina.core.foundation.webdriver.locator.LocatorType;29import com.qaprosoft.carina.core.foundation.webdriver.locator.LocatorUtil;30import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringDecorator;

Full Screen

Full Screen

quitDriver

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;2IDriverPool.quitDriver();3import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;4IDriverPool.getDriver();5import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;6IDriverPool.quitDriver();7import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;8IDriverPool.getDriver();9import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;10IDriverPool.quitDriver();11import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;12IDriverPool.getDriver();13import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;14IDriverPool.quitDriver();15import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;16IDriverPool.getDriver();17import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;18IDriverPool.quitDriver();19import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;20IDriverPool.getDriver();21import com.qaprosoft.carina.core.foundation.webdriver.IDriverPool;22IDriverPool.quitDriver();23import

Full Screen

Full Screen

quitDriver

Using AI Code Generation

copy

Full Screen

1quitDriver();2quitDriver();3quitDriver();4quitDriver();5quitDriver();6quitDriver();7quitDriver();8quitDriver();9quitDriver();10quitDriver();11quitDriver();12quitDriver();13quitDriver();14quitDriver();15quitDriver();16quitDriver();

Full Screen

Full Screen

quitDriver

Using AI Code Generation

copy

Full Screen

1quitDriver();2getDriver();3getDriver("chrome");4getDriver("firefox");5getDriver("android");6getDriver("ios");7getDriver("safari");8getDriver("ie");9getDriver("edge");10getDriver("phantomjs");11getDriver("htmlunit");12getDriver("opera");13getDriver("remote");14getDriver("remote", "chrome");15getDriver("remote", "firefox");16getDriver("remote", "android");17getDriver("remote", "ios");18getDriver("remote", "safari");

Full Screen

Full Screen

quitDriver

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo.gui.components;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.support.FindBy;4import org.openqa.selenium.support.ui.ExpectedConditions;5import org.openqa.selenium.support.ui.WebDriverWait;6import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;7import com.qaprosoft.carina.demo.gui.pages.HomePage;8import com.qaprosoft.carina.demo.gui.pages.LoginPage;9import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;10import com.qaprosoft.carina.core.foundation.webdriver.decorator.PageOpeningStrategy;11import com.qaprosoft.carina.core.foundation.webdriver.decorator.PageOpeningStrategy.PageOpeningStrategyType;12import com.qaprosoft.carina.core.foundation.webdriver.decorator.PageOpeningStrategy;13import com.qaprosoft.carina.core.foundation.webdriver.decorator.PageOpeningStrategy.PageOpeningStrategyType;14import com.qapro

Full Screen

Full Screen

quitDriver

Using AI Code Generation

copy

Full Screen

1public class 1 {2 public static void main(String[] args) {3 WebDriver driver = null;4 try {5 driver = DriverPool.getDriver();6 } finally {7 DriverPool.quitDriver(driver);8 }9 }10}11public class 2 {12 public static void main(String[] args) {13 WebDriver driver = null;14 try {15 driver = DriverPool.getDriver();16 } finally {17 DriverPool.quitDriver(driver);18 }19 }20}21public class 3 {22 public static void main(String[] args) {23 WebDriver driver = null;24 try {25 driver = DriverPool.getDriver();26 } finally {27 DriverPool.quitDriver(driver);28 }29 }30}31public class 4 {32 public static void main(String[] args) {33 WebDriver driver = null;34 try {35 driver = DriverPool.getDriver();36 } finally {37 DriverPool.quitDriver(driver);38 }39 }40}41public class 5 {42 public static void main(String[] args) {43 WebDriver driver = null;44 try {45 driver = DriverPool.getDriver();46 } finally {47 DriverPool.quitDriver(driver);48 }49 }50}51public class 6 {52 public static void main(String[] args) {53 WebDriver driver = null;54 try {55 driver = DriverPool.getDriver();56 } finally {57 DriverPool.quitDriver(driver);58 }59 }60}

Full Screen

Full Screen

quitDriver

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.webdriver;2import java.util.Set;3import org.openqa.selenium.WebDriver;4import org.testng.annotations.Test;5import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.MobileCapabilities;6import com.qaprosoft.carina.core.foundation.webdriver.device.Device;7public class TestIDriverPool {8 public void testQuitDriver() {9 WebDriver driver = IDriverPool.getDefaultDriver();10 Device device = new Device();11 device.setPlatform(MobileCapabilities.IOS);12 device.setUdid("test");13 device.setVersion("12.2");14 IDriverPool.setThreadDevice(device);15 IDriverPool.setThreadDevice(device);16 Set<String> keys = IDriverPool.getDrivers().keySet();17 for (String key : keys) {18 System.out.println(key);19 }20 IDriverPool.quitDriver(driver);21 }22}

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