How to use IOSStartScreenRecordingOptions class of io.appium.java_client.ios package

Best io.appium code snippet using io.appium.java_client.ios.IOSStartScreenRecordingOptions

MobileFactory.java

Source:MobileFactory.java Github

copy

Full Screen

...40import io.appium.java_client.android.AndroidStartScreenRecordingOptions;41import io.appium.java_client.android.AndroidStopScreenRecordingOptions;42import io.appium.java_client.ios.IOSDriver;43import io.appium.java_client.ios.IOSElement;44import io.appium.java_client.ios.IOSStartScreenRecordingOptions;45import io.appium.java_client.ios.IOSStartScreenRecordingOptions.VideoQuality;46import io.appium.java_client.ios.IOSStartScreenRecordingOptions.VideoType;47import io.appium.java_client.ios.IOSStopScreenRecordingOptions;48import io.appium.java_client.screenrecording.ScreenRecordingUploadOptions;49/**50 * MobileFactory creates instance {@link WebDriver} for mobile testing.51 * 52 * @author Alex Khursevich (alex@qaprosoft.com)53 */54public class MobileFactory extends AbstractFactory {55 56 private final static String vnc_mobile = "vnc_mobile";57 58 @Override59 public WebDriver create(String name, Device device, DesiredCapabilities capabilities, String seleniumHost) {60 if (seleniumHost == null) {61 seleniumHost = Configuration.get(Configuration.Parameter.SELENIUM_HOST);62 }63 String driverType = Configuration.getDriverType(capabilities);64 String mobilePlatformName = Configuration.getPlatform();65 // TODO: refactor code to be able to remove SpecialKeywords.CUSTOM property66 // completely67 // use comparison for custom_capabilities here to localize as possible usage of68 // CUSTOM attribute69 String customCapabilities = Configuration.get(Parameter.CUSTOM_CAPABILITIES);70 if (!customCapabilities.isEmpty()) {71 mobilePlatformName = SpecialKeywords.CUSTOM;72 }73 LOGGER.debug("selenium: " + seleniumHost);74 RemoteWebDriver driver = null;75 if (isCapabilitiesEmpty(capabilities)) {76 capabilities = getCapabilities(name, device);77 }78 try {79 if (driverType.equalsIgnoreCase(SpecialKeywords.MOBILE)) {80 EventFiringAppiumCommandExecutor ce = new EventFiringAppiumCommandExecutor(new URL(seleniumHost));81 if (mobilePlatformName.toLowerCase().equalsIgnoreCase(SpecialKeywords.ANDROID)) {82 if (isVideoEnabled()) {83 84 final String videoName = UUID.randomUUID().toString();85 86 AndroidStartScreenRecordingOptions o1 = new AndroidStartScreenRecordingOptions()87 .withVideoSize(R.CONFIG.get("screen_record_size"))88 .withTimeLimit(Duration.ofSeconds(R.CONFIG.getInt("screen_record_duration")))89 .withBitRate(getBitrate(VideoQuality.valueOf(R.CONFIG.get("screen_record_quality"))));90 AndroidStopScreenRecordingOptions o2 = new AndroidStopScreenRecordingOptions()91 .withUploadOptions(new ScreenRecordingUploadOptions()92 .withRemotePath(String.format(R.CONFIG.get("screen_record_ftp"), videoName))93 .withAuthCredentials(R.CONFIG.get("screen_record_user"), R.CONFIG.get("screen_record_pass")));94 ce.getListeners()95 .add(new MobileRecordingListener<AndroidStartScreenRecordingOptions, AndroidStopScreenRecordingOptions>(ce, o1, o2, initVideoArtifact(videoName)));96 }97 driver = new AndroidDriver<AndroidElement>(ce, capabilities);98 } else if (mobilePlatformName.toLowerCase().equalsIgnoreCase(SpecialKeywords.IOS)) {99 if (isVideoEnabled()) {100 101 final String videoName = UUID.randomUUID().toString();102 103 IOSStartScreenRecordingOptions o1 = new IOSStartScreenRecordingOptions()104 .withVideoQuality(VideoQuality.valueOf(R.CONFIG.get("screen_record_quality")))105 .withVideoType(VideoType.MP4)106 .withTimeLimit(Duration.ofSeconds(R.CONFIG.getInt("screen_record_duration")));107 IOSStopScreenRecordingOptions o2 = new IOSStopScreenRecordingOptions()108 .withUploadOptions(new ScreenRecordingUploadOptions()109 .withRemotePath(String.format(R.CONFIG.get("screen_record_ftp"), videoName))110 .withAuthCredentials(R.CONFIG.get("screen_record_user"), R.CONFIG.get("screen_record_pass")));111 ce.getListeners().add(new MobileRecordingListener<IOSStartScreenRecordingOptions, IOSStopScreenRecordingOptions>(ce, o1, o2, initVideoArtifact(videoName)));112 }113 driver = new IOSDriver<IOSElement>(ce, capabilities);114 } else if (mobilePlatformName.toLowerCase().equalsIgnoreCase(SpecialKeywords.CUSTOM)) {115 // that's a case for custom mobile capabilities like browserstack or saucelabs116 driver = new RemoteWebDriver(new URL(seleniumHost), capabilities);117 } else {118 throw new RuntimeException("Unsupported mobile capabilities for type: " + driverType + " platform: " + mobilePlatformName);119 }120 }121 if (device.isNull()) {122 // TODO: double check that local run with direct appium works fine123 RemoteDevice remoteDevice = getDeviceInfo(driver);124 // 3rd party solutions like browserstack or saucelabs return not null125 if (remoteDevice != null && remoteDevice.getName() != null) {...

Full Screen

Full Screen

CommonPage.java

Source:CommonPage.java Github

copy

Full Screen

...21import io.appium.java_client.MobileBy;22import io.appium.java_client.MobileElement;23import io.appium.java_client.TouchAction;24import io.appium.java_client.ios.IOSDriver;25import io.appium.java_client.ios.IOSStartScreenRecordingOptions;26import io.appium.java_client.ios.IOSStartScreenRecordingOptions.VideoQuality;27import io.appium.java_client.touch.WaitOptions;28import io.appium.java_client.touch.offset.PointOption;29import utils.LocProperties;30import utils.log.Log;31public class CommonPage {32 protected static IOSDriver driver = AppiumManager.getManager().getDriver();33 protected static Actions actions;34 private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");35 protected final String packag = LocProperties.getProperties().getProperty("appPackage");36 public CommonPage() {37 actions = new Actions(driver);38 }39 public static void waitByXpath(int timeToWait, String resourceXpath){40 WebDriverWait wait = new WebDriverWait(driver, timeToWait);41 wait.until(ExpectedConditions.visibilityOfElementLocated(MobileBy.xpath(resourceXpath)));42 }43 public static void waitById(int timeToWait, String resourceId){44 WebDriverWait wait = new WebDriverWait(driver, timeToWait);45 wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(resourceId)));46 }47 public static void waitById(int timeToWait, MobileElement mobileElement){48 WebDriverWait wait = new WebDriverWait(driver, timeToWait);49 wait.until(ExpectedConditions.visibilityOf(mobileElement));50 }51 public static void waitByIdInvisible(int timeToWait, String resourceId){52 WebDriverWait wait = new WebDriverWait(driver, timeToWait);53 wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id(resourceId)));54 }55 public static void waitByIdInvisible(int timeToWait, MobileElement mobileElement){56 WebDriverWait wait = new WebDriverWait(driver, timeToWait);57 wait.until(ExpectedConditions.invisibilityOf(mobileElement));58 }59 // The following method should be used only in case implicit/explicit waits are not valid for the60 // scenario. Blocking the thread is not desirable and using it is not a good solution.61 public static void wait(int seconds) {62 try {63 Thread.sleep(seconds*1000);64 } catch (InterruptedException e) {65 e.printStackTrace();66 }67 }68 public MobileElement findXpath(String xpath){69 return (MobileElement) driver.findElement(By.xpath(xpath));70 }71 public static void swipe (double startx, double starty, double endx, double endy) {72 Dimension size = driver.manage().window().getSize();73 int startY=(int)(size.height * starty);74 int endY=(int)(size.height * endy);75 int startX=(int)(size.width * startx);76 int endX=(int)(size.height * endx);77 TouchAction ts = new TouchAction(driver);78 ts.longPress(PointOption.point(startX, startY))79 .moveTo(PointOption.point(startX, endY)).release().perform();80 }81 // This code comes from the Appium official docu82 // http://appium.io/docs/en/writing-running-appium/tutorial/swipe/simple-element/83 public void swipeElementIOS(MobileElement el, String dir) {84 System.out.println("swipeElementIOS(): dir: '" + dir + "'"); // always log your actions85 // Animation default time:86 // - iOS: 200 ms87 // final value depends on your app and could be greater88 final int ANIMATION_TIME = 200; // ms89 final int PRESS_TIME = 500; // ms90 // init screen variables91 Dimension dims = driver.manage().window().getSize();92 Rectangle rect = el.getRect();93 // check element overlaps screen94 if (rect.x >= dims.width || rect.x + rect.width <= 095 || rect.y >= dims.height || rect.y + rect.height <= 0) {96 throw new IllegalArgumentException("swipeElementIOS(): Element outside screen");97 }98 // init borders per your app screen99 // or make them configurable with function variables100 int leftBorder, rightBorder, upBorder, downBorder;101 leftBorder = 0;102 rightBorder = 0;103 upBorder = 0;104 downBorder = 0;105 // find rect that overlap screen106 if (rect.x < 0) {107 rect.width = rect.width + rect.x;108 rect.x = 0;109 }110 if (rect.y < 0) {111 rect.height = rect.height + rect.y;112 rect.y = 0;113 }114 if (rect.width > dims.width)115 rect.width = dims.width;116 if (rect.height > dims.height)117 rect.height = dims.height;118 PointOption pointOptionStart, pointOptionEnd;119 switch (dir) {120 case "DOWN": // from up to down121 pointOptionStart = PointOption.point(rect.x + rect.width / 2,122 rect.y + upBorder);123 pointOptionEnd = PointOption.point(rect.x + rect.width / 2,124 rect.y + rect.height - downBorder);125 break;126 case "UP": // from down to up127 pointOptionStart = PointOption.point(rect.x + rect.width / 2,128 rect.y + rect.height - downBorder);129 pointOptionEnd = PointOption.point(rect.x + rect.width / 2,130 rect.y + upBorder);131 break;132 case "LEFT": // from right to left133 pointOptionStart = PointOption.point(rect.x + rect.width - rightBorder,134 rect.y + rect.height / 2);135 pointOptionEnd = PointOption.point(rect.x + leftBorder,136 rect.y + rect.height / 2);137 break;138 case "RIGHT": // from left to right139 pointOptionStart = PointOption.point(rect.x + leftBorder,140 rect.y + rect.height / 2);141 pointOptionEnd = PointOption.point(rect.x + rect.width - rightBorder,142 rect.y + rect.height / 2);143 break;144 default:145 throw new IllegalArgumentException("swipeElementIOS(): dir: '" + dir + "' NOT supported");146 }147 // execute swipe using TouchAction148 try {149 new TouchAction(driver)150 .press(pointOptionStart)151 // a bit more reliable when we add small wait152 .waitAction(WaitOptions.waitOptions(Duration.ofMillis(PRESS_TIME)))153 .moveTo(pointOptionEnd)154 .release().perform();155 } catch (Exception e) {156 System.err.println("swipeElementIOS(): TouchAction FAILED\n" + e.getMessage());157 return;158 }159 // always allow swipe action to complete160 wait(ANIMATION_TIME/1000);161 }162 public static void takeScreenshot (String name) {163 try {164 String sd = sdf.format(new Timestamp(System.currentTimeMillis()).getTime());165 File screenShotFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);166 FileUtils.copyFile(screenShotFile, new File("screenshots/"+name+"_"+sd+".png"));167 Log.log(Level.FINE,"Take screenshot " + name + " at: " + sd);168 } catch (IOException e) {169 e.printStackTrace();170 }171 }172 public static void startRecording (){173 IOSStartScreenRecordingOptions iOSStartScreenRecordingOptions =174 new IOSStartScreenRecordingOptions()175 .withVideoQuality(VideoQuality.MEDIUM);176 driver.startRecordingScreen(iOSStartScreenRecordingOptions);177 }178 public static void stopRecording (String filename){179 String base64String = driver.stopRecordingScreen();180 byte[] data = Base64.decodeBase64(base64String);181 String destinationPath="video/" + filename + "_" +182 sdf.format(new Timestamp(System.currentTimeMillis()).getTime()) + ".mp4";183 Path path = Paths.get(destinationPath);184 try {185 Files.write(path, data);186 } catch (IOException e) {187 e.printStackTrace();188 }...

Full Screen

Full Screen

TestMobileApp.java

Source:TestMobileApp.java Github

copy

Full Screen

2import io.appium.java_client.AppiumDriver;3import io.appium.java_client.MobileElement;4import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;5import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;6import io.appium.java_client.ios.IOSStartScreenRecordingOptions;7import io.appium.java_client.screenrecording.CanRecordScreen;8import io.qameta.allure.Allure;9import io.qameta.allure.Attachment;10import io.qameta.allure.Feature;11import io.qameta.allure.Step;12import org.junit.jupiter.api.AfterEach;13import org.junit.jupiter.api.BeforeAll;14import org.junit.jupiter.api.TestInstance;15import org.junit.jupiter.params.ParameterizedTest;16import org.junit.jupiter.params.provider.Arguments;17import org.junit.jupiter.params.provider.MethodSource;18import org.openqa.selenium.OutputType;19import org.openqa.selenium.WebElement;20import javax.imageio.ImageIO;21import java.awt.image.BufferedImage;22import java.io.ByteArrayInputStream;23import java.io.ByteArrayOutputStream;24import java.io.File;25import java.io.IOException;26import java.nio.file.Files;27import java.nio.file.Paths;28import java.util.Base64;29import java.util.concurrent.TimeUnit;30import java.util.stream.Stream;31import static org.junit.jupiter.api.Assertions.assertNotNull;32import static org.junit.jupiter.params.provider.Arguments.arguments;33@SuppressWarnings({"SameParameterValue", "FieldCanBeLocal"})34@Feature("Appiumイメージセレクタテスト")35@TestInstance(TestInstance.Lifecycle.PER_CLASS)36class TestMobileApp {37 private AppiumDriver driver;38 private OSBase osInfo;39 @BeforeAll40 void setupClass() {41 }42 @Step("{osName}/イメージセレクタでログイン")43 @ParameterizedTest44 @MethodSource("osMartix")45 void imageSelectorTest(String osName) throws IOException, InterruptedException {46 setup(osName);47 // イメージセレクタ48 WebElement loginElm = driver.findElementByImage(getReferenceImageB64("racine_sut_login.png"));49 // visualization50 String imageResult = loginElm.getAttribute("visual");51 // Allureにアタッチ(サービス関数経由)52 addAttachment(Base64.getDecoder().decode(imageResult), "image-selector");53 loginElm.click();54 Thread.sleep(20000);55 //addAttachment(driver.getScreenshotAs(OutputType.BYTES),"img1");56 // テンプレートマッチング57 OccurrenceMatchingResult result = templateMatch("original_template.png");58 // Allureにアタッチ(サービス関数経由)59 addAttachment(Base64.getDecoder().decode(result.getVisualization()), "template-matched-result");60 assertNotNull(result.getRect());61 }62 Stream<Arguments> osMartix() {63 return Stream.of(64 arguments("ios"),65 arguments("android")66 );67 }68 @AfterEach69 void tearDown() throws IOException {70 if (driver != null) {71 String base64Video = ((CanRecordScreen) driver).stopRecordingScreen();72 String path = String.format("./build/test_%s.mp4",osInfo.osName());73 Files.write(Paths.get(path), Base64.getDecoder().decode(base64Video));74 attachVideo(path);75 driver.closeApp();76 }77 }78 private void setup(String os) {79 osInfo = os.equals("ios")? new IOSBase():new AndroidBase();80 driver = osInfo.driver();81 driver.launchApp();82 driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);83 if (os.equals("ios")) {84 ((IOSBase)osInfo).iosDriver.startRecordingScreen(85 new IOSStartScreenRecordingOptions()86 .withVideoType("libx264")87 .withVideoScale("320:640")88 .withVideoQuality(IOSStartScreenRecordingOptions.VideoQuality.MEDIUM)89 );90 } else {91 ((AndroidBase)osInfo).androidDriver.startRecordingScreen();92 }93 MobileElement loginId = (MobileElement) driver.findElement(osInfo.loginId());94 MobileElement loginPwd = (MobileElement) driver.findElement(osInfo.loginPwd());95 loginId.sendKeys("demo");96 loginPwd.click();97 loginPwd.sendKeys("demo");98 }99 private String getReferenceImageB64(String imageName) throws IOException {100 BufferedImage image = ImageIO.read(new File(osInfo.resourceDir() + imageName));101 ByteArrayOutputStream os = new ByteArrayOutputStream();102 ImageIO.write(image, "png", os);...

Full Screen

Full Screen

AppiumVideoRecorder.java

Source:AppiumVideoRecorder.java Github

copy

Full Screen

2import cucumber.api.Scenario;3import io.appium.java_client.android.AndroidDriver;4import io.appium.java_client.android.AndroidStartScreenRecordingOptions;5import io.appium.java_client.ios.IOSDriver;6import io.appium.java_client.ios.IOSStartScreenRecordingOptions;7import io.appium.java_client.ios.IOSStartScreenRecordingOptions.VideoQuality;8import org.slf4j.Logger;9import org.slf4j.LoggerFactory;10import ru.sbtqa.tag.pagefactory.environment.Environment;11import ru.sbtqa.tag.pagefactory.mobile.properties.MobileConfiguration;12import ru.sbtqa.tag.pagefactory.utils.PathUtils;13import java.io.FileOutputStream;14import java.text.SimpleDateFormat;15import java.time.Duration;16import java.util.Base64;17import java.util.Date;18import static java.lang.String.format;19public class AppiumVideoRecorder {20 private static final Logger LOG = LoggerFactory.getLogger(AppiumVideoRecorder.class);21 private static final MobileConfiguration PROPERTIES = MobileConfiguration.create();22 private static final String VIDEO_FILENAME_TEMPLATE = "%s." + PROPERTIES.getAppiumVideoExtension();23 private final String videoFileName;24 private boolean isRecording = false;25 public AppiumVideoRecorder(Scenario scenario) {26 String scenarioName = scenario != null ? scenario.getName().replace(" ", "_") : PROPERTIES.getAppiumVideoName();27 videoFileName = scenarioName + "-" + format(VIDEO_FILENAME_TEMPLATE, new SimpleDateFormat("yyyy.MM.dd-HH:mm:ss").format(new Date()));28 }29 public void startRecord() {30 if (Environment.isDriverEmpty()) {31 LOG.error("Can't start video recording because driver is null");32 return;33 }34 if (PROPERTIES.getAppiumPlatformName() == PlatformName.IOS) {35 IOSStartScreenRecordingOptions startOptions = new IOSStartScreenRecordingOptions()36 .withVideoType(PROPERTIES.getAppiumVideoType())37 .withVideoScale(PROPERTIES.getAppiumVideoScale())38 .withTimeLimit(Duration.ofSeconds(PROPERTIES.getAppiumTimeLimit()))39 .withVideoQuality(VideoQuality.valueOf(PROPERTIES.getAppiumVideoQuality()))40 .withFps(PROPERTIES.getAppiumVideoFps())41 .enableForcedRestart();42 ((IOSDriver) Environment.getDriverService().getDriver()).startRecordingScreen(startOptions);43 } else {44 AndroidStartScreenRecordingOptions startOptions = new AndroidStartScreenRecordingOptions()45 .withBitRate(PROPERTIES.getAppiumVideoBitRate())46 .withVideoSize(PROPERTIES.getAppiumVideoSize())47 .withTimeLimit(Duration.ofSeconds(PROPERTIES.getAppiumTimeLimit()))48 .enableForcedRestart();49 if (PROPERTIES.getAppiumVideoBugReport()) {...

Full Screen

Full Screen

TestVideoRecord.java

Source:TestVideoRecord.java Github

copy

Full Screen

2import com.aventstack.extentreports.ExtentTest;3import io.appium.java_client.AppiumDriver;4import io.appium.java_client.MobileElement;5import io.appium.java_client.android.AndroidStartScreenRecordingOptions;6import io.appium.java_client.ios.IOSStartScreenRecordingOptions;7import io.appium.java_client.ios.IOSStartScreenRecordingOptions.VideoQuality;8import io.appium.java_client.screenrecording.CanRecordScreen;9import org.apache.commons.codec.binary.Base64;10import java.io.File;11import java.io.IOException;12import java.nio.file.Files;13import java.nio.file.Path;14import java.nio.file.Paths;15import java.time.Duration;16import java.util.Arrays;17public class TestVideoRecord {18 //MODIFICATIONS REQUIRED TO WORK ON BROWSER. DISABLE FOR NOW.19 private final String pathToTestVideoRecord = new PathGeneration().returnUnifiedPathToLogs_Reports("testVideoRecords" + File.separator);20 private final boolean ffmpegVidRecordingActive = Boolean.parseBoolean(new GetPropertiesFromSysOrConfig().getPropertyFromSysOrConfig("ffmpegVidRecordingActive"));21 public void createNewRecording(AppiumDriver<MobileElement> appiumDriver, ExtentTest currentTest, ExtentReportGenerator extentReportGenerator){22 if(ffmpegVidRecordingActive) {23 String currentPlatform = new GetPropertiesFromSysOrConfig().getPropertyFromSysOrConfig("platform");24 if (currentPlatform.equalsIgnoreCase("android")) {25 ((CanRecordScreen) appiumDriver).startRecordingScreen(new AndroidStartScreenRecordingOptions().enableBugReport().withTimeLimit(Duration.ofMinutes(20)));26 } else if (currentPlatform.equalsIgnoreCase("IOS")) {27 ((CanRecordScreen) appiumDriver).startRecordingScreen(new IOSStartScreenRecordingOptions().withTimeLimit(Duration.ofMinutes(20)).withVideoQuality(VideoQuality.MEDIUM)); //.withVideoScale("1280:720") reduces resolution28 }29 extentReportGenerator.addInfoMessage(currentTest, "Test recording started successfully"); //extentReports30 }31 }32 public void endAndProcessCurrentRecording(String passFailSkip, String featureFileId, AppiumDriver<MobileElement> appiumDriver, ExtentTest currentTest, ExtentReportGenerator extentReportGenerator) {33 if (ffmpegVidRecordingActive) {34 String base64String = ((CanRecordScreen) appiumDriver).stopRecordingScreen();35 byte[] data = Base64.decodeBase64(base64String);36 String destinationPath = pathToTestVideoRecord.concat(passFailSkip).concat(File.separator);37 boolean testVideoRecordMade = new File(destinationPath).mkdirs();38 extentReportGenerator.addInfoMessage(currentTest, "Was the Test Video Recording directory made successfully: " + testVideoRecordMade); //extentReports39 Path path = Paths.get(destinationPath.concat(featureFileId).concat(".mpeg4"));40 try {41 Files.write(path, data);...

Full Screen

Full Screen

ScreenRecord.java

Source:ScreenRecord.java Github

copy

Full Screen

1package io.github.martinschneider.appium.advanced.demo5.screenRecord;2import io.appium.java_client.MobileBy;3import io.appium.java_client.ios.IOSDriver;4import io.appium.java_client.ios.IOSStartScreenRecordingOptions;5import java.io.File;6import java.io.IOException;7import java.net.URL;8import java.time.Duration;9import java.util.Base64;10import java.util.List;11import org.apache.commons.io.FileUtils;12import org.junit.jupiter.api.AfterEach;13import org.junit.jupiter.api.BeforeEach;14import org.junit.jupiter.api.Test;15import org.openqa.selenium.By;16import org.openqa.selenium.WebElement;17import org.openqa.selenium.remote.DesiredCapabilities;18import org.openqa.selenium.support.ui.ExpectedConditions;19import org.openqa.selenium.support.ui.WebDriverWait;20/**21 *22 *23 * <h2>Demo Screen recording in appium</h2>24 *25 * Test: Record the test execution video26 *27 * <p>Learning points:28 *29 * <ul>30 * <li>Usage of the Video Record Options in Appium31 * </ul>32 *33 * @author Syam Sasi, syamsasi99@gmail.com34 */35public class ScreenRecord {36 private String APP_IOS = System.getProperty("user.dir") + "/apps/TheApp.app";37 private IOSDriver driver;38 private WebDriverWait wait;39 private static By pickerScreen = MobileBy.AccessibilityId("Picker Demo");40 private static By pickers = MobileBy.className("XCUIElementTypePickerWheel");41 @BeforeEach42 public void setUp() throws IOException {43 DesiredCapabilities capabilities = new DesiredCapabilities();44 capabilities.setCapability("platformName", "iOS");45 capabilities.setCapability("platformVersion", "11.4");46 capabilities.setCapability("deviceName", "iPhone 8");47 capabilities.setCapability("app", APP_IOS);48 driver = new IOSDriver<>(new URL("http://localhost:4723/wd/hub"), capabilities);49 wait = new WebDriverWait(driver, 10);50 }51 @AfterEach52 public void tearDown() {53 if (driver != null) {54 driver.quit();55 }56 }57 @Test58 public void testPicker() throws IOException, InterruptedException {59 IOSStartScreenRecordingOptions iOSStartScreenRecordingOptions =60 new IOSStartScreenRecordingOptions()61 .withVideoQuality(IOSStartScreenRecordingOptions.VideoQuality.HIGH)62 .withTimeLimit(Duration.ofSeconds(1800));63 driver.startRecordingScreen(iOSStartScreenRecordingOptions);64 // get to the picker view65 wait.until(ExpectedConditions.presenceOfElementLocated(pickerScreen)).click();66 // find the picker elements67 List<WebElement> pickerEls =68 wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(pickers));69 // use the sendKeys method to set the picker wheel values directly70 pickerEls.get(0).sendKeys("March");71 pickerEls.get(1).sendKeys("6");72 Thread.sleep(5000);73 String record = driver.stopRecordingScreen();74 byte[] decode = Base64.getDecoder().decode(record);75 File videoFile = new File(new StringBuilder().append("MyVideo.mp4").toString());...

Full Screen

Full Screen

IOSDevice.java

Source:IOSDevice.java Github

copy

Full Screen

...18import com.github.wasiqb.coteafs.appium.device.Device;19import com.github.wasiqb.coteafs.appium.service.AppiumServer;20import io.appium.java_client.MobileElement;21import io.appium.java_client.ios.IOSDriver;22import io.appium.java_client.ios.IOSStartScreenRecordingOptions;23import io.appium.java_client.ios.IOSStartScreenRecordingOptions.VideoQuality;24import io.appium.java_client.ios.IOSStopScreenRecordingOptions;25import io.appium.java_client.ios.IOSTouchAction;26/**27 * @author wasiq.bhamla28 * @since 13-Apr-2017 5:33:35 PM29 */30public class IOSDevice extends Device<IOSDriver<MobileElement>, IOSTouchAction> {31 /**32 * @param server Server instance33 * @param name Server name34 *35 * @author wasiq.bhamla36 * @since 13-Apr-2017 9:12:09 PM37 */38 public IOSDevice (final AppiumServer server, final String name) {39 super (server, name);40 }41 /*42 * (non-Javadoc)43 * @see com.github.wasiqb.coteafs.appium.device.Device#startRecordSetting()44 */45 @SuppressWarnings ("unchecked")46 @Override47 protected IOSStartScreenRecordingOptions startRecordSetting () {48 final IOSStartScreenRecordingOptions options = IOSStartScreenRecordingOptions.startScreenRecordingOptions ();49 final IOSVideoSetting record = this.setting.getPlayback ()50 .getRecording ()51 .getIos ();52 if (record.getQuality () != VideoQuality.MEDIUM) {53 options.withVideoQuality (record.getQuality ());54 }55 if (record.getFps () > 0) {56 options.withFps (record.getFps ());57 }58 if (record.getCodec () != null) {59 options.withVideoType (record.getCodec ());60 }61 return options;62 }...

Full Screen

Full Screen

Capturer.java

Source:Capturer.java Github

copy

Full Screen

1package auto.actions;2import io.appium.java_client.android.AndroidDriver;3import io.appium.java_client.android.AndroidStartScreenRecordingOptions;4import io.appium.java_client.ios.IOSDriver;5import io.appium.java_client.ios.IOSStartScreenRecordingOptions;6import io.appium.java_client.screenrecording.CanRecordScreen;7import org.openqa.selenium.WebDriver;8import org.openqa.selenium.TakesScreenshot;9import org.openqa.selenium.WebElement;10import org.openqa.selenium.OutputType;11import java.time.Duration;12public class Capturer {13 protected WebDriver driver;14 public Capturer setDriver(WebDriver driver){15 this.driver = driver;16 return this;17 }18 public byte[] captureFullScreen(){19 return ((TakesScreenshot) this.driver).getScreenshotAs(OutputType.BYTES);20 }21 public byte[] captureFullScreen(WebDriver driver){22 return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);23 }24 public byte[] takeScreenShot(WebElement element){25 return element.getScreenshotAs(OutputType.BYTES);26 }27 public void startRecording(){28 if (driver instanceof IOSDriver) {29 ((CanRecordScreen) this.driver).startRecordingScreen(30 new IOSStartScreenRecordingOptions()31 .withTimeLimit(Duration.ofHours(1))32 .withVideoQuality(IOSStartScreenRecordingOptions.VideoQuality.LOW)33 .withFps(5)34 .withVideoType("h264")35 .withVideoScale("trunc(iw/2)*2:trunc(ih/2)*2")36 .enableForcedRestart()37 );38 }else if(driver instanceof AndroidDriver){39 ((CanRecordScreen) this.driver).startRecordingScreen(40 new AndroidStartScreenRecordingOptions()41 .withTimeLimit(Duration.ofHours(1))42 .withBitRate(500000) // 500k/s43 .withVideoSize("720x1280")44// .withVideoSize("360x640")45// .enableBugReport() // since Android P46 .enableForcedRestart()...

Full Screen

Full Screen

IOSStartScreenRecordingOptions

Using AI Code Generation

copy

Full Screen

1IOSStartScreenRecordingOptions options = new IOSStartScreenRecordingOptions();2options.withVideoType(IOSStartScreenRecordingOptions.VideoType.FMP4);3options.withVideoQuality(IOSStartScreenRecordingOptions.VideoQuality.LOW);4options.withTimeLimit(Duration.ofMinutes(2));5driver.startRecordingScreen(options);6IOSStopScreenRecordingOptions options = new IOSStopScreenRecordingOptions();7options.withVideoType(IOSStopScreenRecordingOptions.VideoType.FMP4);8driver.stopRecordingScreen(options);9options = IOSStartScreenRecordingOptions()10driver.start_recording_screen(options)11options = IOSStopScreenRecordingOptions()12driver.stop_recording_screen(options)13driver.start_recording_screen(options)14driver.stop_recording_screen(options)15options = IOSStartScreenRecordingOptions()16driver.startRecordingScreen(options)17options = IOSStopScreenRecordingOptions()18driver.stopRecordingScreen(options)

Full Screen

Full Screen

IOSStartScreenRecordingOptions

Using AI Code Generation

copy

Full Screen

1IOSStartScreenRecordingOptions startScreenRecordingOptions = new IOSStartScreenRecordingOptions();2startScreenRecordingOptions.withVideoType(IOSStartScreenRecordingOptions.VideoType.MP4);3startScreenRecordingOptions.withVideoQuality(IOSStartScreenRecordingOptions.VideoQuality.LOW);4startScreenRecordingOptions.withTimeLimit(Duration.ofSeconds(10));5driver.startRecordingScreen(startScreenRecordingOptions);6from appium.webdriver.extensions.ios.screen_record import IOSStartScreenRecordingOptions7options = IOSStartScreenRecordingOptions()8options.video_type(IOSStartScreenRecordingOptions.VideoType.MP4)9options.video_quality(IOSStartScreenRecordingOptions.VideoQuality.LOW)10options.time_limit(Duration.ofSeconds(10))11driver.start_recording_screen(options)12import { IOSStartScreenRecordingOptions } from 'appium.webdriver.extensions.ios.screen_record';13const options = new IOSStartScreenRecordingOptions();14options.videoType(IOSStartScreenRecordingOptions.VideoType.MP4);15options.videoQuality(IOSStartScreenRecordingOptions.VideoQuality.LOW);16options.timeLimit(Duration.ofSeconds(10));17driver.startRecordingScreen(options);18opts.video_type(::Appium::Core::Ios::Device::ScreenRecord::IOSStartScreenRecordingOptions::VideoType::MP4)19opts.video_quality(::Appium::Core::Ios::Device::ScreenRecord::IOSStartScreenRecordingOptions::VideoQuality::LOW)20opts.time_limit(10)21driver.start_recording_screen(opts)22const IOSStartScreenRecordingOptions = require('appium.webdriver.extensions.ios.screen_record').IOSStartScreenRecordingOptions;23const options = new IOSStartScreenRecordingOptions();24options.videoType(IOSStartScreenRecordingOptions.VideoType.MP4);25options.videoQuality(IOSStartScreenRecordingOptions.VideoQuality.LOW);26options.timeLimit(Duration.ofSeconds

Full Screen

Full Screen

IOSStartScreenRecordingOptions

Using AI Code Generation

copy

Full Screen

1IOSStartScreenRecordingOptions options = new IOSStartScreenRecordingOptions();2options.withVideoType("h264");3options.withVideoQuality("medium");4options.withVideoFps(10);5options.withTimeLimit("30");6driver.startRecordingScreen(options);7#code to use IOSStartScreenRecordingOptions class of appium.webdriver.extensions.ios.ios import IOSStartScreenRecordingOptions8options = IOSStartScreenRecordingOptions()9self.start_recording_screen(options)10driver.start_recording_screen(options)11$options = new IOSStartScreenRecordingOptions();12$options->setVideoType("h264");13$options->setVideoQuality("medium");14$options->setVideoFps(10);15$options->setTimeLimit("30");16$driver->startRecordingScreen($options);17var options = new IOSStartScreenRecordingOptions();18options.VideoType = "h264";19options.VideoQuality = "medium";20options.VideoFps = 10;21options.TimeLimit = "30";22driver.StartRecordingScreen(options);23const options = new IOSStartScreenRecordingOptions();24options.videoType = 'h264';25options.videoQuality = 'medium';26options.videoFps = 10;27options.timeLimit = '30';28await this.startRecordingScreen(options);

Full Screen

Full Screen

IOSStartScreenRecordingOptions

Using AI Code Generation

copy

Full Screen

1IOSStartScreenRecordingOptions startOptions = new IOSStartScreenRecordingOptions();2startOptions.withVideoType("h264");3startOptions.withVideoQuality("medium");4startOptions.withVideoScale(100);5startOptions.withTimeLimit(Duration.ofMinutes(3));6startOptions.withVideoFps(30);7driver.startRecordingScreen(startOptions);8IOSStopScreenRecordingOptions stopOptions = new IOSStopScreenRecordingOptions();9stopOptions.withVideoType("mjpeg");10stopOptions.withVideoQuality("low");11driver.stopRecordingScreen(stopOptions);12IOSStartScreenRecordingOptions startOptions = new IOSStartScreenRecordingOptions();13startOptions.videoType("h264");14startOptions.videoQuality("medium");15startOptions.videoScale(100);16startOptions.timeLimit(Duration.ofMinutes(3));17startOptions.videoFps(30);18driver.startRecordingScreen(startOptions);19IOSStopScreenRecordingOptions stopOptions = new IOSStopScreenRecordingOptions();20stopOptions.videoType("mjpeg");21stopOptions.videoQuality("low");22driver.stopRecordingScreen(stopOptions);23IOSStartScreenRecordingOptions startOptions = new IOSStartScreenRecordingOptions();24startOptions.setVideoType("h264");25startOptions.setVideoQuality("medium");26startOptions.setVideoScale(100);27startOptions.setTimeLimit(Duration.ofMinutes(3));28startOptions.setVideoFps(30);29driver.startRecordingScreen(startOptions);30IOSStopScreenRecordingOptions stopOptions = new IOSStopScreenRecordingOptions();31stopOptions.setVideoType("mjpeg");32stopOptions.setVideoQuality("low");33driver.stopRecordingScreen(stopOptions);34IOSStartScreenRecordingOptions startOptions = new IOSStartScreenRecordingOptions();35startOptions.setVideoType("h264");36startOptions.setVideoQuality("medium");37startOptions.setVideoScale(100);38startOptions.setTimeLimit(Duration.ofMinutes

Full Screen

Full Screen

IOSStartScreenRecordingOptions

Using AI Code Generation

copy

Full Screen

1IOSStartScreenRecordingOptions options = new IOSStartScreenRecordingOptions();2options.withVideoType("h264");3options.withVideoQuality("medium");4options.withVideoFps(10);5options.withTimeLimit("10s");6driver.startRecordingScreen(options);7IOSStopScreenRecordingOptions options = new IOSStopScreenRecordingOptions();8options.withVideoType("h264");9options.withVideoQuality("medium");10options.withVideoFps(10);11options.withTimeLimit("10s");12driver.stopRecordingScreen(options);13const IOSStartScreenRecordingOptions = require('../../io/appium/java_client/ios/IOSStartScreenRecordingOptions');14const IOSStopScreenRecordingOptions = require('../../io/appium/java_client/ios/IOSStopScreenRecordingOptions');15const options = new IOSStartScreenRecordingOptions();16options.withVideoType("h264");17options.withVideoQuality("medium");18options.withVideoFps(10);19options.withTimeLimit("10s");20await driver.startRecordingScreen(options);21const IOSStopScreenRecordingOptions = require('../../io/appium/java_client/ios/IOSStopScreenRecordingOptions');22const options = new IOSStopScreenRecordingOptions();23options.withVideoType("h264");24options.withVideoQuality("medium");25options.withVideoFps(10);26options.withTimeLimit("10s");27await driver.stopRecordingScreen(options);28from appium.webdriver.common.mobileby import MobileBy29from appium.webdriver.extensions.ios.iosstartscreenrecordingoptions import IOSStartScreenRecordingOptions30from appium.webdriver.extensions.ios.iosstopscreenrecordingoptions import IOSStopScreenRecordingOptions31options = IOSStartScreenRecordingOptions()32options.video_type("h264")33options.video_quality("medium")34options.video_fps(10)35options.time_limit("10s")36driver.start_recording_screen(options)37from appium.webdriver.common.mobileby import MobileBy

Full Screen

Full Screen

IOSStartScreenRecordingOptions

Using AI Code Generation

copy

Full Screen

1IOSStartScreenRecordingOptions options = new IOSStartScreenRecordingOptions();2options.withVideoType("h264");3options.withVideoQuality("medium");4options.withVideoFps(10);5options.withTimeLimit("30", TimeUnit.SECONDS);6driver.startRecordingScreen(options);7IOSStopScreenRecordingOptions options = new IOSStopScreenRecordingOptions();8options.withVideoType("h264");9options.withVideoQuality("medium");10options.withVideoFps(10);11options.withTimeLimit("30", TimeUnit.SECONDS);12driver.stopRecordingScreen(options);13IOSStartScreenRecordingOptions options = new IOSStartScreenRecordingOptions();14options.withVideoType("h264");15options.withVideoQuality("medium");16options.withVideoFps(10);17options.withTimeLimit("30", TimeUnit.SECONDS);18driver.startRecordingScreen(options);19IOSStopScreenRecordingOptions options = new IOSStopScreenRecordingOptions();20options.withVideoType("h264");21options.withVideoQuality("medium");22options.withVideoFps(10);23options.withTimeLimit("30", TimeUnit.SECONDS);24driver.stopRecordingScreen(options);25IOSStartScreenRecordingOptions options = new IOSStartScreenRecordingOptions();26options.withVideoType("h264");27options.withVideoQuality("medium");28options.withVideoFps(10);29options.withTimeLimit("30", TimeUnit.SECONDS);30driver.startRecordingScreen(options);31IOSStopScreenRecordingOptions options = new IOSStopScreenRecordingOptions();32options.withVideoType("h264");33options.withVideoQuality("medium");34options.withVideoFps(10);35options.withTimeLimit("30", TimeUnit.SECONDS);36driver.stopRecordingScreen(options);37IOSStartScreenRecordingOptions options = new IOSStartScreenRecordingOptions();

Full Screen

Full Screen

IOSStartScreenRecordingOptions

Using AI Code Generation

copy

Full Screen

1package appium.java;2import java.net.MalformedURLException;3import java.net.URL;4import java.util.HashMap;5import java.util.Map;6import org.openqa.selenium.remote.DesiredCapabilities;7import io.appium.java_client.ios.IOSStartScreenRecordingOptions;8import io.appium.java_client.remote.MobileCapabilityType;9import io.appium.java_client.remote.MobilePlatform;10import io.appium.java_client.remote.MobileRecordingScreenOptions;11import io.appium.java_client.ios.IOSDriver;12public class StartScreenRecording {13 public static void main(String[] args) throws MalformedURLException, InterruptedException {14 DesiredCapabilities capabilities = new DesiredCapabilities();15 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);16 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8");17 capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.4");18 capabilities.setCapability(MobileCapabilityType.APP, "/Users/username/Library/Developer/Xcode/DerivedData/UICatalog-ehvzjxkqzqkqygcjwqwxwqkqjydx/Build/Products/Debug-iphonesimulator/UICatalog.app");

Full Screen

Full Screen

IOSStartScreenRecordingOptions

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.ios.IOSStartScreenRecordingOptions;2import org.openqa.selenium.OutputType;3import org.openqa.selenium.TakesScreenshot;4import org.openqa.selenium.remote.RemoteWebDriver;5import java.io.File;6import java.io.IOException;7import java.nio.file.Files;8import java.nio.file.Paths;9import java.time.Duration;10import java.util.Date;11import java.util.HashMap;12import java.util.Map;13import java.util.concurrent.TimeUnit;14public class IOSStartScreenRecordingOptionsExample {15 public static void main(String[] args) throws IOException {16 IOSStartScreenRecordingOptions startScreenRecordingOptions = new IOSStartScreenRecordingOptions();17 startScreenRecordingOptions.withVideoType("h264");18 startScreenRecordingOptions.withVideoQuality("medium");19 startScreenRecordingOptions.withTimeLimit(Duration.ofSeconds(30));20 startScreenRecordingOptions.withVideoScale("640:480");

Full Screen

Full Screen

IOSStartScreenRecordingOptions

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.ios.IOSStartScreenRecordingOptions;2import java.util.HashMap;3import java.util.Map;4import java.time.Duration;5new IOSStartScreenRecordingOptions();6Map<String, Object> videoQuality = new HashMap<>();7videoQuality.put("type", "h264");8videoQuality.put("width", 1280);9videoQuality.put("height", 720);10videoQuality.put("bitrate", 1000000);11startScreenRecordingOptions.videoQuality(videoQuality);12startScreenRecordingOptions.withVideoType("h264");13startScreenRecordingOptions.withVideoFps(30);14startScreenRecordingOptions.withTimeLimit(Duration.ofSeconds(30));15driver.startRecordingScreen(startScreenRecordingOptions);16import io.appium.java_client.ios.IOSStopScreenRecordingOptions;17import java.util.Base64;18new IOSStopScreenRecordingOptions();19stopScreenRecordingOptions.withVideoType("h264");20stopScreenRecordingOptions.withVideoQuality("medium");21stopScreenRecordingOptions.withVideoScale(2);22String base64EncodedString = driver.stopRecordingScreen(stopScreenRecordingOptions);23byte[] decodedBytes = Base64.getDecoder().decode(base64EncodedString);24String decodedString = new String(decodedBytes);25System.out.println("Decoded String is: " + decodedString);26from appium.webdriver.extensions.ios.screen_record import IOSStartScreenRecordingOptions27start_screen_recording_options = IOSStartScreenRecordingOptions()28start_screen_recording_options.video_quality("medium")29start_screen_recording_options.video_scale(2)30start_screen_recording_options.video_type("h264")31start_screen_recording_options.time_limit(30)32driver.start_recording_screen(start_screen_recording_options)33from appium.webdriver.extensions.ios.screen_record import IOSStopScreenRecordingOptions34stop_screen_recording_options = IOSStopScreenRecordingOptions()35stop_screen_recording_options.video_type("h264")36stop_screen_recording_options.video_quality("medium")

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 io.appium 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