How to use down method of org.openqa.selenium.remote.RemoteTouchScreen class

Best Selenium code snippet using org.openqa.selenium.remote.RemoteTouchScreen.down

Source:AppiumIosTest.java Github

copy

Full Screen

1/**2 * Candybean is a next generation automation and testing framework suite.3 * It is a collection of components that foster test automation, execution4 * configuration, data abstraction, results illustration, tag-based execution,5 * top-down and bottom-up batches, mobile variants, test translation across6 * languages, plain-language testing, and web service testing.7 * Copyright (C) 2013 SugarCRM, Inc. <candybean@sugarcrm.com>8 *9 * This program is free software: you can redistribute it and/or modify10 * it under the terms of the GNU Affero General Public License as11 * published by the Free Software Foundation, either version 3 of the12 * License, or (at your option) any later version.13 *14 * This program is distributed in the hope that it will be useful,15 * but WITHOUT ANY WARRANTY; without even the implied warranty of16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 * GNU Affero General Public License for more details.18 *19 * You should have received a copy of the GNU Affero General Public License...

Full Screen

Full Screen

Source:EvernoteAndroidTest.java Github

copy

Full Screen

1package com.sugarcrm.candybean.examples.mobile;2import static org.junit.Assert.*;3import java.net.URL;4import java.util.Calendar;5import java.util.HashMap;6import java.util.List;7import org.junit.After;8import org.junit.Before;9import org.junit.BeforeClass;10import org.junit.Ignore;11import org.junit.Test;12import org.openqa.selenium.By;13import org.openqa.selenium.Capabilities;14import org.openqa.selenium.JavascriptExecutor;15import org.openqa.selenium.NoSuchElementException;16import org.openqa.selenium.WebDriverException;17import org.openqa.selenium.WebElement;18import org.openqa.selenium.interactions.HasTouchScreen;19import org.openqa.selenium.interactions.TouchScreen;20import org.openqa.selenium.remote.RemoteTouchScreen;21import org.openqa.selenium.remote.RemoteWebDriver;22import org.openqa.selenium.remote.RemoteWebElement;23import com.sugarcrm.candybean.automation.AutomationInterfaceBuilder;24import com.sugarcrm.candybean.automation.Candybean;25import com.sugarcrm.candybean.automation.AutomationInterface.Type;26import com.sugarcrm.candybean.automation.webdriver.WebDriverInterface;27import com.sugarcrm.candybean.exceptions.CandybeanException;28public class EvernoteAndroidTest {29 public static WebDriverInterface iface;30 @BeforeClass31 public static void beforeClass() throws CandybeanException{32 Candybean candybean = Candybean.getInstance();33 AutomationInterfaceBuilder builder = candybean.getAIB(EvernoteAndroidTest.class);34 builder.setType(Type.ANDROID);35 iface = builder.build();36 }37 38 @Before39 public void setUp() throws CandybeanException {40 iface.start();41 iface.pause(3000);42 login();43 closeWelcomeOverlay();44 }45 46 @After47 public void tearDown() throws CandybeanException {48 iface.stop();49 }50 @Ignore51 @Test52 public void openNotes() throws CandybeanException {53 openUsersMenu();54 WebElement notesAction = iface.wd.findElements(55 By.id("com.evernote:id/home_list_text")).get(0);56 notesAction.click();57 iface.pause(3000);58 }59 @Test60 public void newNote() throws CandybeanException {61 openUsersMenu();62 WebElement newNoteButton = iface.wd.findElement(By63 .id("com.evernote:id/btn_new_note"));64 newNoteButton.click();65 iface.pause(2000);66 WebElement noteTitleField = iface.wd.findElement(By67 .id("com.evernote:id/note_title"));68 noteTitleField.click();69 iface.pause(1000);70 noteTitleField.sendKeys(Calendar.getInstance().getTime().toString());71 WebElement noteField = iface.wd72 .findElement(By.id("com.evernote:id/text"));73 noteField.click();74 iface.pause(1000);75 noteField76 .sendKeys("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "77 + "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud "78 + "exercitation ullamco laboris nis");79 iface.wd.findElement(By.className("android.widget.ImageButton")).click();80 iface.pause(2000);81 }82 @Ignore83 @Test84 public void deleteAllNotes() throws CandybeanException {85 openNotes();86 List<WebElement> notes = iface.wd.findElements(By87 .id("com.evernote:id/title"));88 while (notes.size() != 0) {89 WebElement note = notes.get(0);90 HashMap<String, String> values = new HashMap<String, String>();91 values.put("element", ((RemoteWebElement) note).getId());92 ((JavascriptExecutor) iface.wd).executeScript("mobile: longClick", values);93 iface.pause(1000);94 WebElement footer = ((RemoteWebDriver) iface.wd)95 .findElementById("com.evernote:id/efab_menu_footer");96 List<WebElement> footerItems = footer.findElements(By97 .className("android.widget.ImageButton"));98 WebElement moreOptions = footerItems.get(footerItems.size() - 1);99 moreOptions.click();100 iface.pause(1000);101 WebElement deleteButton = iface.wd.findElements(102 By.id("com.evernote:id/item_title")).get(5);103 deleteButton.click();104 iface.pause(1000);105 WebElement deleteConfirmation = iface.wd.findElement(By106 .id("android:id/button1"));107 deleteConfirmation.click();108 iface.pause(1000);109 notes = iface.wd.findElements(By.id("com.evernote:id/title"));110 }111 assertEquals(iface.wd.findElements(By.id("com.evernote:id/title")).size(), 0);112 }113 @Ignore114 @Test115 public void openNotebookFromShortcut() throws CandybeanException {116 openShortcutsMenu();117 WebElement shortcut = iface.wd.findElement(By118 .id("com.evernote:id/shortcut_name"));119 shortcut.click();120 iface.pause(1000);121 }122 @Ignore123 @Test124 public void signOut() throws CandybeanException {125 openUsersMenu();126 openUserMenu();127 WebElement signoutButton = iface.wd.findElements(By.id("com.evernote:id/item_title")).get(1);128 signoutButton.click();129 iface.pause(1000);130 closeConfirmation(true);131 iface.pause(4000);132 }133 134 private boolean isLoggedIn() {135 try {136 openUsersMenu();137 WebElement userDropDown = iface.wd.findElement(By.id("com.evernote:id/signed_in_user_area"));138 return userDropDown.isDisplayed();139 } catch (Exception e) {140 return false;141 }142 }143 144 private boolean overlayExists(){145 try {146 WebElement welcomeOverlay = iface.wd.findElement(By.id("com.evernote:id/fd_layout"));147 return welcomeOverlay.isDisplayed();148 } catch (Exception e) {149 return false;150 }151 }152 153 private boolean isLeftMenuOpen(){154 try {155 WebElement header = iface.wd.findElement(By.id("com.evernote:id/efab_menu_hdr"));156 List<WebElement> children = header.findElements(By.xpath("android.widget.LinearLayout"));157 return children.size() == 2;158 } catch (Exception e) {159 return false;160 }161 }162 public void closeWelcomeOverlay() throws CandybeanException {163 if(overlayExists()){164 try {165 WebElement welcomeOverlay = iface.wd.findElement(By.id("com.evernote:id/fd_layout"));166 WebElement closeOverlayButton = welcomeOverlay.findElement(By.className("android.widget.ImageView"));167 closeOverlayButton.click();168 iface.pause(1000);169 } catch (NoSuchElementException e) {170 return;171 }172 }173 }174 public void login() throws CandybeanException {175 if(isLoggedIn())176 return;177 for(int i = 0; i < 2; i++){178 openRightSideMenu();179 iface.pause(1000);180 }181 WebElement emailTextField = iface.wd.findElement(By182 .id("com.evernote:id/landing_username"));183 emailTextField.clear();184 emailTextField.sendKeys("sfarooq@sugarcrm.com");185 WebElement passwordField = iface.wd.findElement(By186 .id("com.evernote:id/landing_password"));187 passwordField.click();188 passwordField.sendKeys("candybeantest");189 WebElement logInButton = iface.wd.findElement(By190 .id("com.evernote:id/landing_sign_in_button"));191 logInButton.click();192 iface.pause(5000);193 }194 public void openUserMenu() throws CandybeanException {195 WebElement userDropDown = iface.wd.findElement(By196 .id("com.evernote:id/signed_in_user_area"));197 userDropDown.click();198 iface.pause(1000);199 }200 201 public void closeConfirmation(boolean option) throws CandybeanException {202 WebElement confirmation = iface.wd.findElement(By203 .id(option ? "android:id/button1" : "android:id/button2"));204 confirmation.click();205 iface.pause(1000);206 }207 public String getFooterTitleText() {208 WebElement startingElement = iface.wd.findElement(By209 .id("com.evernote:id/footer_title"));210 return startingElement.getText();211 }212 public void swipe(double startX, double startY, double endX, double endY,213 double duration) {214 JavascriptExecutor js = (JavascriptExecutor) iface.wd;215 HashMap<String, Double> swipeObject = new HashMap<String, Double>();216 swipeObject.put("startX", startX);217 swipeObject.put("startY", startY);218 swipeObject.put("endX", endX);219 swipeObject.put("endY", endY);220 swipeObject.put("duration", duration);221 js.executeScript("mobile: swipe", swipeObject);222 }223 224 public void openShortcutsMenu() throws CandybeanException {225 openRightSideMenu();226 openRightSideMenu();227 iface.pause(3000);228 }229 public void openRightSideMenu() throws CandybeanException {230 try {231 swipe(0.9, 0.5, 0.1, 0.5, 0.2);232 iface.pause(1000);233 } catch (WebDriverException e) {234 return;235 }236 }237 public void openUsersMenu() throws CandybeanException {238 try {239 if(isLeftMenuOpen())240 return;241 swipe(0.1, 0.5, 0.9, 0.5, 0.2);242 iface.pause(1000);243 } catch (WebDriverException e) {244 return;245 }246 }247 public class SwipeableWebDriver extends RemoteWebDriver implements248 HasTouchScreen {249 private RemoteTouchScreen touch;250 public SwipeableWebDriver(URL remoteAddress,251 Capabilities desiredCapabilities) {252 super(remoteAddress, desiredCapabilities);253 touch = new RemoteTouchScreen(getExecuteMethod());254 }255 public TouchScreen getTouch() {256 return touch;257 }258 }259}...

Full Screen

Full Screen

Source:CallingCardTestSauceLab.java Github

copy

Full Screen

1package org.lfreeman.callingcard;2import static org.junit.Assert.assertEquals;3import static org.junit.Assert.assertTrue;4import java.io.BufferedOutputStream;5import java.io.File;6import java.io.FileInputStream;7import java.io.FileOutputStream;8import java.io.IOException;9import java.net.URI;10import java.net.URL;11import java.text.MessageFormat;12import java.util.HashMap;13import java.util.Map;14import java.util.Properties;15import java.util.concurrent.TimeUnit;16import java.util.zip.ZipEntry;17import java.util.zip.ZipOutputStream;18import org.apache.http.HttpEntity;19import org.apache.http.auth.AuthScope;20import org.apache.http.auth.UsernamePasswordCredentials;21import org.apache.http.client.CredentialsProvider;22import org.apache.http.client.methods.CloseableHttpResponse;23import org.apache.http.client.methods.HttpPost;24import org.apache.http.client.utils.URIBuilder;25import org.apache.http.entity.ContentType;26import org.apache.http.entity.FileEntity;27import org.apache.http.impl.client.BasicCredentialsProvider;28import org.apache.http.impl.client.CloseableHttpClient;29import org.apache.http.impl.client.HttpClients;30import org.apache.http.util.EntityUtils;31import org.junit.After;32import org.junit.Before;33import org.junit.BeforeClass;34import org.junit.Test;35import org.openqa.selenium.By;36import org.openqa.selenium.Capabilities;37import org.openqa.selenium.JavascriptExecutor;38import org.openqa.selenium.WebDriver;39import org.openqa.selenium.WebElement;40import org.openqa.selenium.interactions.HasTouchScreen;41import org.openqa.selenium.interactions.TouchScreen;42import org.openqa.selenium.remote.CapabilityType;43import org.openqa.selenium.remote.DesiredCapabilities;44import org.openqa.selenium.remote.RemoteTouchScreen;45import org.openqa.selenium.remote.RemoteWebDriver;46public class CallingCardTestSauceLab {47 private WebDriver driver;48 private static String sauceUserName;49 private static String sauceAccessKey;50 @BeforeClass51 public static void oneTimeSetUp() throws Exception {52 loadProperties();53 File classpathRoot = new File(System.getProperty("user.dir"));54 File appDir = new File(classpathRoot, "app");55 //compress apk and load it to saucelabs storage56 compressFile(appDir.getAbsolutePath(), "callingcard.apk", "callingcard.zip");57 uploadFile(appDir.getAbsolutePath(), "callingcard.zip", sauceUserName,58 sauceAccessKey);59 }60 @Before61 public void setUp() throws Exception {62 DesiredCapabilities capabilities = new DesiredCapabilities();63 capabilities.setCapability("device", "Android");64 capabilities.setCapability(CapabilityType.BROWSER_NAME, "");65 capabilities.setCapability(CapabilityType.VERSION, "4.2");66 capabilities.setCapability(CapabilityType.PLATFORM, "MAC");67 capabilities.setCapability("app", "sauce-storage:callingcard.zip");68 capabilities.setCapability("app-package", "org.lfreeman.callingcard");69 capabilities.setCapability("app-activity", "org.lfreeman.callingcard.CalingCard");70 driver = new SwipeableWebDriver(new URL(MessageFormat.format(71 "http://{0}:{1}@ondemand.saucelabs.com:80/wd/hub", sauceUserName, sauceAccessKey)),72 capabilities);73 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);74 }75 @After76 public void tearDown() throws Exception {77 this.driver.quit();78 }79 @Test80 public void testClear() throws InterruptedException {81 assertTrue(this.isOnCallingCardScreen());82 this.typeAccesscode("17185121518");83 this.clear();84 assertTrue(this.getAccessCode().isEmpty());85 this.pressHome();86 this.launchCallingCardApp();87 assertTrue(this.getAccessCode().isEmpty());88 }89 @Test90 public void testSave() throws InterruptedException {91 String code = "17185121518";92 assertTrue(this.isOnCallingCardScreen());93 this.typeAccesscode(code);94 this.save();95 this.launchCallingCardApp();96 assertEquals(this.getAccessCode(), code);97 }98 private boolean isOnCallingCardScreen() {99 String text = "CallingCard";100 WebElement el = driver.findElement(By.name(text));101 return el.getText().equals(text);102 }103 private void save() {104 driver.findElement(By.name("Save")).click();105 }106 private void clear() {107 driver.findElement(By.name("Clear")).click();108 }109 private void typeAccesscode(String code) {110 String text = "editTextAccessNumber";111 driver.findElement(By.name(text)).sendKeys(code);112 // required if emulator is configured without hardware keyboard113 // driver.navigate().back();114 }115 private String getAccessCode() {116 String text = "editTextAccessNumber";117 return driver.findElement(By.name(text)).getText();118 }119 private void launchCallingCardApp() {120 driver.findElement(By.name("Apps")).click();121 driver.findElement(By.name("CallingCard")).click();122 }123 public void pressHome() {124 Map<String, Integer> keycode = new HashMap<>();125 keycode.put("keycode", 3);126 ((JavascriptExecutor) driver).executeScript("mobile: keyevent", keycode);127 }128 private static void loadProperties() {129 Properties prop = new Properties();130 try {131 prop.load(new FileInputStream("config.properties"));132 sauceUserName = prop.getProperty("sauceUserName");133 sauceAccessKey = prop.getProperty("sauceAccessKey");134 } catch (IOException ex) {135 ex.printStackTrace();136 }137 }138 /**139 * Compress apk file140 * 141 * @param directory142 * @param file143 * @param zipFileName144 */145 private static void compressFile(String directory, String file, String zipFileName) {146 File source = new File(directory, file);147 File destination = new File(directory, zipFileName);148 byte[] buffer = new byte[1024];149 try (FileOutputStream fos = new FileOutputStream(destination);150 BufferedOutputStream bos = new BufferedOutputStream(fos);151 ZipOutputStream zos = new ZipOutputStream(bos)) {152 ZipEntry ze = new ZipEntry(file);153 zos.putNextEntry(ze);154 FileInputStream in = new FileInputStream(source);155 int len;156 while ((len = in.read(buffer)) > 0) {157 zos.write(buffer, 0, len);158 }159 in.close();160 zos.closeEntry();161 System.out.println("Done");162 } catch (IOException ex) {163 ex.printStackTrace();164 }165 }166 /**167 * Upload compressed apk file to Saucelabs168 * https://saucelabs.com/appium/tutorial/3 (Appium for Android on Sauce Labs)169 * 170 * @param directory171 * @param fileName172 * @param username173 * @param password174 * @throws Exception175 */176 private static void uploadFile(String directory, String fileName, String username,177 String password) throws Exception {178 File source = new File(directory, fileName);179 String filePath = source.getAbsolutePath();180 URI uri = new URIBuilder().setScheme("http").setHost("saucelabs.com")181 .setPath(String.format("/rest/v1/storage/%s/%s", username, fileName))182 .setParameter("overwrite", "true").build();183 CredentialsProvider credsProvider = new BasicCredentialsProvider();184 credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username,185 password));186 CloseableHttpClient httpclient = HttpClients.custom()187 .setDefaultCredentialsProvider(credsProvider).build();188 try {189 HttpPost httpPost = new HttpPost(uri);190 File file = new File(filePath);191 FileEntity entity = new FileEntity(file, ContentType.APPLICATION_OCTET_STREAM);192 httpPost.setEntity(entity);193 System.out.println("executing request" + httpPost.getRequestLine());194 CloseableHttpResponse response2 = httpclient.execute(httpPost);195 try {196 System.out.println(response2.getStatusLine());197 HttpEntity entity2 = response2.getEntity();198 EntityUtils.consume(entity2);199 } finally {200 response2.close();201 }202 } finally {203 httpclient.close();204 }205 }206 public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {207 private RemoteTouchScreen touch;208 public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {209 super(remoteAddress, desiredCapabilities);210 touch = new RemoteTouchScreen(getExecuteMethod());211 }212 public TouchScreen getTouch() {213 return touch;214 }215 }216}...

Full Screen

Full Screen

Source:SugarAndroidTest.java Github

copy

Full Screen

1/**2 * Candybean is a next generation automation and testing framework suite.3 * It is a collection of components that foster test automation, execution4 * configuration, data abstraction, results illustration, tag-based execution,5 * top-down and bottom-up batches, mobile variants, test translation across6 * languages, plain-language testing, and web service testing.7 * Copyright (C) 2013 SugarCRM, Inc. <candybean@sugarcrm.com>8 *9 * This program is free software: you can redistribute it and/or modify10 * it under the terms of the GNU Affero General Public License as11 * published by the Free Software Foundation, either version 3 of the12 * License, or (at your option) any later version.13 *14 * This program is distributed in the hope that it will be useful,15 * but WITHOUT ANY WARRANTY; without even the implied warranty of16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 * GNU Affero General Public License for more details.18 *19 * You should have received a copy of the GNU Affero General Public License...

Full Screen

Full Screen

Source:NTC_WorkOuts_FindWorkOuts.java Github

copy

Full Screen

1package com.Workouts;2import io.appium.java_client.AppiumDriver;3import io.appium.java_client.MobileElement;4import java.io.File;5import java.net.MalformedURLException;6import java.net.URL;7import java.util.List;8import java.util.Set;9import java.util.concurrent.TimeUnit;10import org.apache.commons.io.FileUtils;11import org.junit.After;12import org.junit.Before;13import org.openqa.selenium.By;14import org.openqa.selenium.Capabilities;15import org.openqa.selenium.ContextAware;16import org.openqa.selenium.OutputType;17import org.openqa.selenium.Platform;18import org.openqa.selenium.TakesScreenshot;19import org.openqa.selenium.WebDriver;20import org.openqa.selenium.WebElement;21import org.openqa.selenium.interactions.HasTouchScreen;22import org.openqa.selenium.interactions.TouchScreen;23import org.openqa.selenium.remote.Augmenter;24import org.openqa.selenium.remote.CapabilityType;25import org.openqa.selenium.remote.DesiredCapabilities;26import org.openqa.selenium.remote.RemoteTouchScreen;27import org.openqa.selenium.remote.RemoteWebDriver;28import org.openqa.selenium.support.pagefactory.ByChained;29import org.openqa.selenium.support.ui.ExpectedConditions;30import org.openqa.selenium.support.ui.WebDriverWait;31import org.testng.annotations.AfterMethod;32import org.testng.annotations.BeforeMethod;33import org.testng.annotations.BeforeTest;34import org.testng.annotations.Test;35import com.opera.core.systems.scope.services.WindowManager;36public class NTC_WorkOuts_FindWorkOuts {37 WebElement findButton;38 WebDriver driver;39 40 @Test41 public void signIn() throws Exception {42 File appDir = new File("D:\\Workspace\\APKs");43 File app = new File(appDir, "com.nike.ntc.apk"); 44 DesiredCapabilities capabilities = new DesiredCapabilities();45 capabilities.setCapability("deviceName", "nirajbrands");46 capabilities.setCapability(CapabilityType.BROWSER_NAME, "");47 capabilities.setCapability(CapabilityType.VERSION, "4.3");48 capabilities.setCapability(CapabilityType.PLATFORM, Platform.WINDOWS);49 capabilities.setCapability("platformName", "Android");50 capabilities.setCapability("autoLaunch", true);51 capabilities.setCapability("device", "Android");52 capabilities.setCapability("appPackage", "com.nike.ntc");53 capabilities.setCapability("app", app.getAbsolutePath());54 55 capabilities.setCapability("appActivity", ".ui.TourAndLoginActivity"); 56 try 57 {58 AppiumDriver driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);59 60 //click on "Accept"61 findButton = driver.findElement(By.name("Accept"));62 findButton.click();63 System.out.println("Clicked on 'Accept' Button");64 //click on "GET STARTED"65 findButton = driver.findElement(By.name("GET STARTED"));66 findButton.click();67 System.out.println("Clicked on 'GET STARTED' Button");68 69 Thread.sleep(10000); //wait for web elements to load70 71 //find all web elements72 List <WebElement> element = driver.findElements(By.className("android.widget.EditText"));73 //select Email TextBOX74 findButton = element.get(0);75 findButton.sendKeys("nike2222@nike.com");76 77 System.out.println("Data FED into 'EMAIL' TextBOX");78 Thread.sleep(5000); //wait for data to be fed in "Email" TextBOX79 80 //select "Password" TextBOX81 findButton = element.get(1);82 findButton.sendKeys("Nike1234"); //wait for data to be fed in Password TextBOX83 84 System.out.println("Data FED into 'Password' TextBOX");85 Thread.sleep(5000); 86 87 driver.hideKeyboard();88 89 //find "SIGN IN" button90 findButton = driver.findElement(By.className("android.widget.Button"));91 findButton.click(); //click on "SIGN IN" button 92 System.out.println("Clicked on 'SIGN IN' Button");93 94 Thread.sleep(15000);95 96 //click on "OKAY, LET'S GO"97 findButton = driver.findElement(By.name("OKAY, LET'S GO"));98 findButton.click();99 System.out.println("Clicked on 'OKAY, LET'S GO' Button");100 101 Thread.sleep(5000);102 103 //click on "FIND WORKOUTS"104 findButton = driver.findElement(By.name("FIND WORKOUTS"));105 findButton.click();106 System.out.println("Clicked on 'FIND WORKOUTS' Button");107 108 } 109 110 catch (MalformedURLException e) 111 {112 e.printStackTrace();113 114 }115 116 117 }118 @After119 public void tearDown() throws Exception 120 {121 driver.quit();122 }123 124}...

Full Screen

Full Screen

Source:CallingCardTest.java Github

copy

Full Screen

1package org.lfreeman.callingcard;2import static org.junit.Assert.assertEquals;3import static org.junit.Assert.assertTrue;4import java.io.File;5import java.net.URL;6import java.util.HashMap;7import java.util.Map;8import java.util.concurrent.TimeUnit;9import org.junit.After;10import org.junit.Before;11import org.junit.Test;12import org.openqa.selenium.By;13import org.openqa.selenium.Capabilities;14import org.openqa.selenium.JavascriptExecutor;15import org.openqa.selenium.WebDriver;16import org.openqa.selenium.WebElement;17import org.openqa.selenium.interactions.HasTouchScreen;18import org.openqa.selenium.interactions.TouchScreen;19import org.openqa.selenium.remote.CapabilityType;20import org.openqa.selenium.remote.DesiredCapabilities;21import org.openqa.selenium.remote.RemoteTouchScreen;22import org.openqa.selenium.remote.RemoteWebDriver;23public class CallingCardTest {24 private WebDriver driver;25 @Before26 public void setUp() throws Exception {27 File classpathRoot = new File(System.getProperty("user.dir"));28 File appDir = new File(classpathRoot, "app");29 File app = new File(appDir, "callingcard.apk");30 DesiredCapabilities capabilities = new DesiredCapabilities();31 capabilities.setCapability("device", "Android");32 capabilities.setCapability(CapabilityType.BROWSER_NAME, "");33 capabilities.setCapability(CapabilityType.VERSION, "4.2");34 capabilities.setCapability(CapabilityType.PLATFORM, "MAC");35 capabilities.setCapability("app", app.getAbsolutePath());36 capabilities.setCapability("app-package", "org.lfreeman.callingcard");37 capabilities.setCapability("app-activity", "org.lfreeman.callingcard.CalingCard");38 this.driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);39 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);40 }41 @After42 public void tearDown() throws Exception {43 this.driver.quit();44 }45 @Test46 public void testClear() throws InterruptedException {47 assertTrue(this.isOnCallingCardScreen());48 this.typeAccesscode("17185121518");49 this.clear();50 assertTrue(this.getAccessCode().isEmpty());51 this.pressHome();52 this.launchCallingCardApp();53 assertTrue(this.getAccessCode().isEmpty());54 }55 @Test56 public void testSave() throws InterruptedException {57 String code = "17185121518";58 assertTrue(this.isOnCallingCardScreen());59 this.typeAccesscode(code);60 this.save();61 this.launchCallingCardApp();62 assertEquals(this.getAccessCode(), code);63 }64 private boolean isOnCallingCardScreen() {65 String text = "CallingCard";66 WebElement el = driver.findElement(By.name(text));67 return el.getText().equals(text);68 }69 private void save() {70 driver.findElement(By.name("Save")).click();71 }72 private void clear() {73 driver.findElement(By.name("Clear")).click();74 }75 private void typeAccesscode(String code) {76 String text = "editTextAccessNumber";77 driver.findElement(By.name(text)).sendKeys(code);78 // required if emulator is configured without hardware keyboard79 // driver.navigate().back();80 }81 private String getAccessCode() {82 String text = "editTextAccessNumber";83 return driver.findElement(By.name(text)).getText();84 }85 private void launchCallingCardApp() {86 driver.findElement(By.name("Apps")).click();87 driver.findElement(By.name("CallingCard")).click();88 }89 public void pressHome() {90 Map<String, Integer> keycode = new HashMap<>();91 keycode.put("keycode", 3);92 ((JavascriptExecutor) driver).executeScript("mobile: keyevent", keycode);93 }94 public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {95 private RemoteTouchScreen touch;96 public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {97 super(remoteAddress, desiredCapabilities);98 touch = new RemoteTouchScreen(getExecuteMethod());99 }100 public TouchScreen getTouch() {101 return touch;102 }103 }104}...

Full Screen

Full Screen

Source:RemoteTouchScreen.java Github

copy

Full Screen

...17 Map<String, Object> singleTapParams = CoordinatesUtils.paramsFromCoordinates(where);18 executeMethod.execute("touchSingleTap", singleTapParams);19 }20 21 public void down(int x, int y) {22 Map<String, Object> downParams = new HashMap();23 downParams.put("x", Integer.valueOf(x));24 downParams.put("y", Integer.valueOf(y));25 executeMethod.execute("touchDown", downParams);26 }27 28 public void up(int x, int y) {29 Map<String, Object> upParams = new HashMap();30 upParams.put("x", Integer.valueOf(x));31 upParams.put("y", Integer.valueOf(y));32 executeMethod.execute("touchUp", upParams);33 }34 35 public void move(int x, int y) {36 Map<String, Object> moveParams = new HashMap();37 moveParams.put("x", Integer.valueOf(x));38 moveParams.put("y", Integer.valueOf(y));39 executeMethod.execute("touchMove", moveParams);...

Full Screen

Full Screen

Source:AppiumTest.java Github

copy

Full Screen

1import java.io.File;2import java.net.URL;3import java.util.List;4import io.appium.java_client.AppiumDriver;5import io.appium.java_client.android.AndroidDriver;6import org.junit.After;7import org.junit.Before;8import org.junit.Ignore;9import org.junit.Test;10import org.openqa.selenium.By;11import org.openqa.selenium.Capabilities;12import org.openqa.selenium.WebDriver;13import org.openqa.selenium.WebElement;14import org.openqa.selenium.interactions.HasTouchScreen;15import org.openqa.selenium.interactions.TouchScreen;16import org.openqa.selenium.remote.CapabilityType;17import org.openqa.selenium.remote.DesiredCapabilities;18import org.openqa.selenium.remote.RemoteTouchScreen;19import org.openqa.selenium.remote.RemoteWebDriver;20public class AppiumTest {21 private AndroidDriver driver;22 @Before23 public void setUp() throws Exception {24 // set up appium25 File appDir = new File("../moodly-android/app/build/outputs/apk/");26 File app = new File(appDir, "app-release.apk");27 DesiredCapabilities capabilities = new DesiredCapabilities();28 capabilities.setCapability("platformName", "Android");29 capabilities.setCapability("deviceName", "appium-test");30 capabilities.setCapability(CapabilityType.BROWSER_NAME, "");31 capabilities.setCapability(CapabilityType.VERSION, "4.2");32 capabilities.setCapability(CapabilityType.PLATFORM, "WINDOW");33 capabilities.setCapability("app", app.getAbsolutePath());34 capabilities.setCapability("app-package", "com.leanovate.moodly.app");35 capabilities.setCapability("appActivity", ".Settings");36 driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);37 }38 @After39 public void tearDown() throws Exception {40 driver.quit();41 }42 @Test43 public void shouldUpdateSettings() throws InterruptedException {44 updateSettings();45 }46 private void updateSettings() {47 WebElement moodlyId = driver.findElement(By.id("com.leanovate.moodly.app:id/moodlyIdValue"));48 WebElement host = driver.findElement(By.id("com.leanovate.moodly.app:id/hostValue"));49 WebElement updateButton = driver.findElement(By.id("com.leanovate.moodly.app:id/updateSettings"));50 moodlyId.clear();51 moodlyId.sendKeys("bc16b958-d8c5-1004-8b85-dc068a7baf30");52 host.clear();53 host.sendKeys("moodly-alpha.herokuapp.com");54 updateButton.click();55 }56}...

Full Screen

Full Screen

down

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.By; 2import org.openqa.selenium.WebDriver; 3import org.openqa.selenium.WebElement; 4import org.openqa.selenium.remote.RemoteTouchScreen; 5import org.openqa.selenium.remote.RemoteWebDriver; 6import org.openqa.selenium.support.ui.ExpectedConditions; 7import org.openqa.selenium.support.ui.WebDriverWait; 8import java.net.URL; 9import java.util.concurrent.TimeUnit; 10import org.openqa.selenium.remote.DesiredCapabilities; 11import org.openqa.selenium.remote.RemoteTouchScreen; 12import org.openqa.selenium.remote.RemoteWebElement; 13import org.openqa.selenium.support.ui.ExpectedConditions; 14import org.openqa.selenium.support.ui.WebDriverWait; 15import org.openqa.selenium.By; 16import org.openqa.selenium.Dimension; 17import org.openqa.selenium.WebElement; 18import org.openqa.selenium.remote.DesiredCapabilities; 19import org.openqa.selenium.remote.RemoteWebDriver; 20import java.net.URL; 21import java.util.concurrent.TimeUnit; 22import org.openqa.selenium.remote.RemoteTouchScreen; 23import org.openqa.selenium.remote.RemoteWebElement; 24import org.openqa.selenium.support.ui.ExpectedConditions; 25import org.openqa.selenium.support.ui.WebDriverWait; 26import org.openqa.selenium.By; 27import org.openqa.selenium.Dimension; 28import org.openqa.selenium.WebElement; 29import org.openqa.selenium.remote.DesiredCapabilities; 30import org.openqa.selenium.remote.RemoteWebDriver; 31import java.net.URL; 32import java.util.concurrent.TimeUnit; 33import org.openqa.selenium.remote.RemoteTouchScreen; 34import org.openqa.selenium.remote.RemoteWebElement; 35import org.openqa.selenium.support.ui.ExpectedConditions; 36import org.openqa.selenium.support.ui.WebDriverWait; 37import org.openqa.selenium.By; 38import org.openqa.selenium.Dimension; 39import org.openqa.selenium.WebElement; 40import org.openqa.selenium.remote.DesiredCapabilities; 41import org.openqa.selenium.remote.RemoteWebDriver; 42import java.net.URL; 43import java.util.concurrent.TimeUnit; 44import org.openqa.selenium.remote.RemoteTouchScreen; 45import org.openqa.selenium.remote.RemoteWebElement; 46import org.openqa.selenium.support.ui.ExpectedConditions; 47import org.openqa.selenium.support.ui.WebDriverWait; 48import org.openqa.selenium.By; 49import org.openqa.selenium.Dimension; 50import org.openqa.selenium.WebElement; 51import org.openqa.selenium.remote.DesiredCapabilities; 52import org.openqa.selenium.remote.RemoteWebDriver; 53import java.net.URL; 54import java.util.concurrent.TimeUnit; 55import org.openqa.selenium.remote.RemoteTouchScreen; 56import org.openqa.selenium.remote.RemoteWebElement; 57import org.openqa.selenium.support.ui.ExpectedConditions; 58import org.openqa.selenium.support.ui.WebDriverWait

Full Screen

Full Screen

down

Using AI Code Generation

copy

Full Screen

1RemoteTouchScreen touch = new RemoteTouchScreen(driver.getWebDriver());2touch.down(100, 100);3touch.up(100, 100);4RemoteTouchScreen touch = new RemoteTouchScreen(driver.getWebDriver());5touch.down(100, 100);6touch.up(100, 100);7RemoteTouchScreen touch = new RemoteTouchScreen(driver.getWebDriver());8touch.down(100, 100);9touch.up(100, 100);10RemoteTouchScreen touch = new RemoteTouchScreen(driver.getWebDriver());11touch.down(100, 100);12touch.up(100, 100);13RemoteTouchScreen touch = new RemoteTouchScreen(driver.getWebDriver());14touch.down(100, 100);15touch.up(100, 100);16RemoteTouchScreen touch = new RemoteTouchScreen(driver.getWebDriver());17touch.down(100, 100);18touch.up(100, 100);19RemoteTouchScreen touch = new RemoteTouchScreen(driver.getWebDriver());20touch.down(100, 100);21touch.up(100, 100);22RemoteTouchScreen touch = new RemoteTouchScreen(driver.getWebDriver());23touch.down(100, 100);24touch.up(100,

Full Screen

Full Screen

down

Using AI Code Generation

copy

Full Screen

1package com.automation;2import io.appium.java_client.android.AndroidDriver;3import io.appium.java_client.remote.MobileCapabilityType;4import java.io.File;5import java.io.IOException;6import java.net.URL;7import org.openqa.selenium.By;8import org.openqa.selenium.remote.DesiredCapabilities;9import org.openqa.selenium.remote.RemoteTouchScreen;10import org.testng.annotations.AfterTest;11import org.testng.annotations.BeforeTest;12import org.testng.annotations.Test;13public class Scroll {14private AndroidDriver driver;15private RemoteTouchScreen touch;16public void setUp() throws IOException {17File classpathRoot = new File(System.getProperty("user.dir"));18File appDir = new File(classpathRoot, "/Apps/");19File app = new File(appDir, "ApiDemos-debug.apk");20DesiredCapabilities capabilities = new DesiredCapabilities();21capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");22capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "4.4");23capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");24capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");25capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

Full Screen

Full Screen

down

Using AI Code Generation

copy

Full Screen

1RemoteTouchScreen remoteTouchScreen = new RemoteTouchScreen(driver);2remoteTouchScreen.scroll(0, -100);3RemoteTouchScreen remoteTouchScreen = new RemoteTouchScreen(driver);4remoteTouchScreen.scroll(0, 100);5RemoteTouchScreen remoteTouchScreen = new RemoteTouchScreen(driver);6remoteTouchScreen.scroll(100, 0);7RemoteTouchScreen remoteTouchScreen = new RemoteTouchScreen(driver);8remoteTouchScreen.scroll(-100, 0);

Full Screen

Full Screen

down

Using AI Code Generation

copy

Full Screen

1package org.openqa.selenium.remote;2public interface RemoteTouchScreen extends TouchScreen {3 RemoteTouchScreen down(int pixels);4}5package org.openqa.selenium.remote;6public interface RemoteTouchScreen extends TouchScreen {7 RemoteTouchScreen down(int pixels);8}9package org.openqa.selenium.remote;10public interface RemoteTouchScreen extends TouchScreen {11 RemoteTouchScreen down(int pixels);12}13package org.openqa.selenium.remote;14public interface RemoteTouchScreen extends TouchScreen {15 RemoteTouchScreen down(int pixels);16}17package org.openqa.selenium.remote;18public interface RemoteTouchScreen extends TouchScreen {19 RemoteTouchScreen down(int pixels);20}

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

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

Most used method in RemoteTouchScreen

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful