How to use EventFiringAppiumCommandExecutor class of com.qaprosoft.carina.core.foundation.webdriver.listener package

Best Carina code snippet using com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumCommandExecutor

Source:MobileFactory.java Github

copy

Full Screen

...32import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.MobileCapabilies;33import com.qaprosoft.carina.core.foundation.webdriver.core.factory.AbstractFactory;34import com.qaprosoft.carina.core.foundation.webdriver.device.Device;35import com.qaprosoft.carina.core.foundation.webdriver.device.DevicePool;36import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumCommandExecutor;37import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileRecordingListener;38import io.appium.java_client.android.AndroidDriver;39import io.appium.java_client.android.AndroidElement;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()...

Full Screen

Full Screen

Source:EventFiringAppiumCommandExecutor.java Github

copy

Full Screen

...39import io.appium.java_client.MobileCommand;40import io.appium.java_client.remote.AppiumCommandExecutor;41import io.appium.java_client.remote.AppiumW3CHttpCommandCodec;42/**43 * EventFiringAppiumCommandExecutor triggers event listener before/after execution of the command.44 * Please track {@link AppiumCommandExecutor} for latest changes.45 * 46 * @author akhursevich47 */48@SuppressWarnings({ "unchecked" })49public class EventFiringAppiumCommandExecutor extends HttpCommandExecutor {50 51 private final Optional<DriverService> serviceOptional;52 private EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands, DriverService service,53 URL addressOfRemoteServer,54 HttpClient.Factory httpClientFactory) {55 super(additionalCommands,56 ofNullable(service)57 .map(DriverService::getUrl)58 .orElse(addressOfRemoteServer),59 httpClientFactory);60 serviceOptional = ofNullable(service);61 }62 public EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands, DriverService service,63 HttpClient.Factory httpClientFactory) {64 this(additionalCommands, checkNotNull(service), null, httpClientFactory);65 }66 public EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,67 URL addressOfRemoteServer, HttpClient.Factory httpClientFactory) {68 this(additionalCommands, null, checkNotNull(addressOfRemoteServer), httpClientFactory);69 }70 public EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,71 URL addressOfRemoteServer) {72 this(additionalCommands, addressOfRemoteServer, new HttpClientFactoryCustom());73 }74 public EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,75 DriverService service) {76 this(additionalCommands, service, new HttpClientFactoryCustom());77 }78 public EventFiringAppiumCommandExecutor(URL addressOfRemoteServer) {79 this(MobileCommand.commandRepository, addressOfRemoteServer, new HttpClientFactoryCustom());80 }81 private <B> B getPrivateFieldValue(String fieldName, Class<B> fieldType) {82 try {83 final Field f = getClass().getSuperclass().getDeclaredField(fieldName);84 f.setAccessible(true);85 return fieldType.cast(f.get(this));86 } catch (NoSuchFieldException | IllegalAccessException e) {87 throw new WebDriverException(e);88 }89 }90 private void setPrivateFieldValue(String fieldName, Object newValue) {91 try {92 final Field f = getClass().getSuperclass().getDeclaredField(fieldName);...

Full Screen

Full Screen

EventFiringAppiumCommandExecutor

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriver;2import org.openqa.selenium.remote.DesiredCapabilities;3import org.testng.annotations.Test;4import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumCommandExecutor;5import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumCommandExecutor.EventHandler;6import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumCommandExecutor.EventType;7import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumCommandExecutor.EventValue;8import io.appium.java_client.AppiumDriver;9import io.appium.java_client.MobileElement;10import io.appium.java_client.android.AndroidDriver;11public class AppiumCommandExecutorTest {12 public void testAppiumCommandExecutor() throws Exception {13 DesiredCapabilities capabilities = new DesiredCapabilities();14 capabilities.setCapability("deviceName", "Android Emulator");15 capabilities.setCapability("platformName", "Android");16 capabilities.setCapability("platformVersion", "7.0");17 capabilities.setCapability("appPackage", "com.android.calculator2");18 capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");19 WebDriver driver = new AndroidDriver<MobileElement>(new EventFiringAppiumCommandExecutor(capabilities, new EventHandler() {20 public void handleEvent(EventType type, EventValue value) {21 System.out.println("Event Type: " + type);22 System.out.println("Event Value: " + value);23 }24 }), capabilities);25 AppiumDriver<MobileElement> appiumDriver = (AppiumDriver<MobileElement>) driver;26 appiumDriver.findElementById("com.android.calculator2:id/digit_1").click();27 appiumDriver.findElementById("com.android.calculator2:id/op_add").click();28 appiumDriver.findElementById("com.android.calculator2:id/digit_2").click();29 appiumDriver.findElementById("com.android.calculator2:id/eq").click();30 appiumDriver.quit();31 }32}33Event Value: {"cmd":"newSession","args":[{"deviceName":"Android Emulator","platformName":"Android","platformVersion":"7.0","appPackage":"com.android.calculator2","appActivity":"com.android.calculator2.Calculator","automationName":"Appium","appium-version":"1.7

Full Screen

Full Screen

EventFiringAppiumCommandExecutor

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumCommandExecutor;2import io.appium.java_client.AppiumDriver;3import io.appium.java_client.MobileElement;4import io.appium.java_client.android.AndroidDriver;5import io.appium.java_client.android.AndroidElement;6import io.appium.java_client.events.api.general.AppiumWebDriverEventListener;7import io.appium.java_client.remote.MobileCapabilityType;8import org.openqa.selenium.By;9import org.openqa.selenium.WebDriver;10import org.openqa.selenium.remote.DesiredCapabilities;11import java.net.MalformedURLException;12import java.net.URL;13import java.util.concurrent.TimeUnit;14public class AppiumDriverFactory {15 public static AppiumDriver<MobileElement> createAppiumDriver(String platform) throws MalformedURLException {16 AppiumDriver<MobileElement> driver = null;17 DesiredCapabilities capabilities = new DesiredCapabilities();18 EventFiringAppiumCommandExecutor eventFiringAppiumCommandExecutor = null;19 AppiumWebDriverEventListener listener = new AppiumWebDriverEventListenerImpl();20 switch (platform) {21 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");22 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");23 capabilities.setCapability(MobileCapabilityType.APP, "C:\\Users\\User\\Desktop\\app-debug.apk");24 capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);

Full Screen

Full Screen

EventFiringAppiumCommandExecutor

Using AI Code Generation

copy

Full Screen

1public class TestAppiumCommandExecutor extends TestBase {2 @Test(description = "Test to verify AppiumCommandExecutor")3 public void testAppiumCommandExecutor() {4 executor.addListener(new AppiumCommandListener());5 WebDriver driver = new AppiumDriver(executor);6 ((AppiumDriver)driver).launchApp();7 }8}9public class TestAppiumCommandExecutor extends TestBase {10 @Test(description = "Test to verify AppiumCommandExecutor")11 public void testAppiumCommandExecutor() {12 executor.addListener(new AppiumCommandListener());13 WebDriver driver = new AppiumDriver(executor);14 ((AppiumDriver)driver).launchApp();15 }16}17public class TestAppiumCommandExecutor extends TestBase {18 @Test(description = "Test to verify AppiumCommandExecutor")19 public void testAppiumCommandExecutor() {20 executor.addListener(new AppiumCommandListener());21 WebDriver driver = new AppiumDriver(executor);22 ((AppiumDriver)driver).launchApp();23 }24}25public class TestAppiumCommandExecutor extends TestBase {26 @Test(description = "Test to verify AppiumCommandExecutor")27 public void testAppiumCommandExecutor() {28 executor.addListener(new AppiumCommandListener());29 WebDriver driver = new AppiumDriver(executor);30 ((AppiumDriver)driver).launchApp();31 }32}

Full Screen

Full Screen

EventFiringAppiumCommandExecutor

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.webdriver.decorator;2import java.lang.reflect.Constructor;3import java.lang.reflect.InvocationTargetException;4import java.lang.reflect.Method;5import java.util.ArrayList;6import java.util.List;7import org.openqa.selenium.WebDriver;8import org.openqa.selenium.WebElement;9import org.openqa.selenium.interactions.Locatable;10import org.openqa.selenium.interactions.internal.Coordinates;11import org.openqa.selenium.remote.CommandExecutor;12import org.openqa.selenium.remote.RemoteWebDriver;13import org.openqa.selenium.remote.RemoteWebElement;14import org.openqa.selenium.support.pagefactory.ElementLocator;15import org.openqa.selenium.support.ui.Duration;16import org.openqa.selenium.support.ui.Sleeper;17import org.openqa.selenium.support.ui.SystemClock;18import org.slf4j.Logger;19import org.slf4j.LoggerFactory;20public class ExtendedFieldDecorator extends ExtendedElementLocatorFactory implements org.openqa.selenium.support.pagefactory.ElementDecorator {21 private static final Logger LOGGER = LoggerFactory.getLogger(ExtendedFieldDecorator.class);22 private RemoteWebDriver driver;23 private Sleeper sleeper;24 public ExtendedFieldDecorator(RemoteWebDriver driver) {25 super(driver);26 this.driver = driver;27 sleeper = new Sleeper(new SystemClock(), Duration.ofMillis(500));28 }29 public ExtendedFieldDecorator(RemoteWebDriver driver, ElementLocatorFactory factory) {30 super(driver, factory);31 this.driver = driver;32 sleeper = new Sleeper(new SystemClock(), Duration.ofMillis(500));33 }34 public Object decorate(ClassLoader loader, Method method) {35 if (isDecoratableList(method)) {36 return decorateList(loader, method);37 } else if (isDecoratableElement(method)) {38 return decorateElement(loader, method);39 } else {40 return null;41 }42 }43 private boolean isDecoratableElement(Method method) {44 return WebElement.class.isAssignableFrom(method.getReturnType());45 }46 private boolean isDecoratableList(Method method) {47 return List.class.isAssignableFrom(method.getReturnType());48 }49 private Object decorateList(ClassLoader loader, Method method) {50 ElementLocator locator = factory.createLocator(method);51 if (locator == null) {52 return null;53 }54 List<Object> proxyList = new ArrayList<Object>();55 for (WebElement element : locator.findElements()) {56 proxyList.add(decorateElement(loader, element, method));57 }

Full Screen

Full Screen

EventFiringAppiumCommandExecutor

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.webdriver.listener;2import java.util.EventListener;3import org.openqa.selenium.WebDriver;4public interface DriverCommandExecutionListener extends EventListener {5 void beforeDriverCommandExecution(WebDriver driver, DriverCommandExecutionDetails commandDetails);6 void afterDriverCommandExecution(WebDriver driver, DriverCommandExecutionDetails commandDetails);7}8package com.qaprosoft.carina.core.foundation.webdriver.listener;9import java.util.EventListener;10import org.openqa.selenium.WebDriver;11public interface DriverCommandExecutionListener extends EventListener {12 void beforeDriverCommandExecution(WebDriver driver, DriverCommandExecutionDetails commandDetails);13 void afterDriverCommandExecution(WebDriver driver, DriverCommandExecutionDetails commandDetails);14}15package com.qaprosoft.carina.core.foundation.webdriver.listener;16import java.util.EventListener;17import org.openqa.selenium.WebDriver;18public interface DriverCommandExecutionListener extends EventListener {19 void beforeDriverCommandExecution(WebDriver driver, DriverCommandExecutionDetails commandDetails);20 void afterDriverCommandExecution(WebDriver driver, DriverCommandExecutionDetails commandDetails);21}

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.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful