Почему приложение IOS не перезапускается после каждого сценария с огурцом? ⇐ IOS
Почему приложение IOS не перезапускается после каждого сценария с огурцом?
I do setup an autoamtion framework for mobile with java and appium. And came across an issue with the IOS part. The app is not relaunching after each cucumber scenario, even if I initilize the driver every time in @Before Hook. (same approach works for android).
package stepdef; import com.qa.utils.*; import io.cucumber.java.After; import io.cucumber.java.Before; import io.cucumber.java.Scenario; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import androidPages.BasePage; public class Hooks extends BasePage { protected static final Logger logger = LogManager.getLogger(Hooks.class); DriverManager driverManager = new DriverManager(); @Before public void initialize() throws Exception { driverManager.initializeDriver(); } @After public void quit(Scenario scenario) throws InterruptedException { DriverManager driverManager = new DriverManager(); if (scenario.isFailed()) { byte[] screenshot = ((TakesScreenshot) driverManager.getDriver()).getScreenshotAs(OutputType.BYTES); scenario.attach(screenshot, "image/png", "FailedScreenshot"); } driverManager.getDriver().quit(); } } This is the DriverManager calss:
import io.appium.java_client.AppiumDriver; import io.appium.java_client.ios.IOSDriver; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; import java.net.URL; import java.util.Properties; public class DriverManager { private static final ThreadLocal driver = new ThreadLocal(); protected final Logger logger = LogManager.getLogger(this.getClass()); public AppiumDriver getDriver() { return driver.get(); } public void setDriver(AppiumDriver driver2) { driver.set(driver2); } public void initializeDriver() throws Exception { AppiumDriver driver = null; Properties props = new PropertyManager().getProps(); URL serverUrl = new URL(props.getProperty("appiumURL")); try { switch (props.getProperty("platformName")) { case "android_emulator": driver = new AppiumDriver(serverUrl, new CapabilitiesManager().getCaps()); case "ios_emulator": driver = new AppiumDriver(serverUrl, new CapabilitiesManager().getCaps()); logger.info(">>>>>>The driver initialized"); } if (driver == null) { throw new Exception("driver is null. ABORT!!!"); } this.driver.set(driver); } catch (IOException e) { e.printStackTrace(); throw e; } } } Why for android it is relaunching the app every time, but for IOS the app remains open and continue from where it left? How to fix that ?
Источник: https://stackoverflow.com/questions/781 ... r-scenario
I do setup an autoamtion framework for mobile with java and appium. And came across an issue with the IOS part. The app is not relaunching after each cucumber scenario, even if I initilize the driver every time in @Before Hook. (same approach works for android).
package stepdef; import com.qa.utils.*; import io.cucumber.java.After; import io.cucumber.java.Before; import io.cucumber.java.Scenario; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import androidPages.BasePage; public class Hooks extends BasePage { protected static final Logger logger = LogManager.getLogger(Hooks.class); DriverManager driverManager = new DriverManager(); @Before public void initialize() throws Exception { driverManager.initializeDriver(); } @After public void quit(Scenario scenario) throws InterruptedException { DriverManager driverManager = new DriverManager(); if (scenario.isFailed()) { byte[] screenshot = ((TakesScreenshot) driverManager.getDriver()).getScreenshotAs(OutputType.BYTES); scenario.attach(screenshot, "image/png", "FailedScreenshot"); } driverManager.getDriver().quit(); } } This is the DriverManager calss:
import io.appium.java_client.AppiumDriver; import io.appium.java_client.ios.IOSDriver; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; import java.net.URL; import java.util.Properties; public class DriverManager { private static final ThreadLocal driver = new ThreadLocal(); protected final Logger logger = LogManager.getLogger(this.getClass()); public AppiumDriver getDriver() { return driver.get(); } public void setDriver(AppiumDriver driver2) { driver.set(driver2); } public void initializeDriver() throws Exception { AppiumDriver driver = null; Properties props = new PropertyManager().getProps(); URL serverUrl = new URL(props.getProperty("appiumURL")); try { switch (props.getProperty("platformName")) { case "android_emulator": driver = new AppiumDriver(serverUrl, new CapabilitiesManager().getCaps()); case "ios_emulator": driver = new AppiumDriver(serverUrl, new CapabilitiesManager().getCaps()); logger.info(">>>>>>The driver initialized"); } if (driver == null) { throw new Exception("driver is null. ABORT!!!"); } this.driver.set(driver); } catch (IOException e) { e.printStackTrace(); throw e; } } } Why for android it is relaunching the app every time, but for IOS the app remains open and continue from where it left? How to fix that ?
Источник: https://stackoverflow.com/questions/781 ... r-scenario
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение