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

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

Source:AppiumAndroidTest.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 License20 * along with this program. If not, see <http://www.gnu.org/licenses/>.21 */22package com.sugarcrm.candybean.examples.mobile;23import org.junit.After;24import org.junit.Before;25import org.junit.Test;26import org.json.simple.JSONObject;27import org.json.simple.parser.JSONParser;28import org.apache.http.util.EntityUtils;29import org.apache.http.HttpEntity;30import org.apache.http.HttpResponse;31import org.apache.http.client.methods.HttpGet;32import org.apache.http.impl.client.DefaultHttpClient;33import org.openqa.selenium.By;34import org.openqa.selenium.WebDriver;35import org.openqa.selenium.WebElement;36import org.openqa.selenium.Point;37import org.openqa.selenium.interactions.HasTouchScreen;38import org.openqa.selenium.Capabilities;39import org.openqa.selenium.interactions.TouchScreen;40import org.openqa.selenium.remote.CapabilityType;41import org.openqa.selenium.remote.DesiredCapabilities;42import org.openqa.selenium.remote.RemoteWebDriver;43import org.openqa.selenium.remote.RemoteTouchScreen;44import org.openqa.selenium.interactions.touch.TouchActions;45import java.net.URL;46import java.util.ArrayList;47import java.util.List;48import java.util.Random;49import static org.junit.Assert.assertEquals;50import static org.junit.Assert.assertTrue;51/**52 * Simple <a href="https://github.com/appium/appium">Appium</a> test which runs against an appium server deployed53 * with a 'TestApp' Android project.54 *55 * @author Larry Cao56 */57public class AppiumAndroidTest {58 private WebDriver driver;59 private List<Integer> values;60 private static final int MINIMUM = 0;61 private static final int MAXIMUM = 10;62 @Before63 public void setUp() throws Exception {64 // set up appium65 DesiredCapabilities capabilities = new DesiredCapabilities();66 capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");67 capabilities.setCapability(CapabilityType.VERSION, "4.2.2");68 capabilities.setCapability("device", "Android");69 capabilities.setCapability(CapabilityType.PLATFORM, "Mac");70 capabilities.setCapability("app", "https://s3.amazonaws.com/voodoo2/TestApp.apk.zip");71 capabilities.setCapability("app-package", "com.example.TestApp");72 capabilities.setCapability("app-activity", "MyActivity");73 driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);74 values = new ArrayList<>();75 }76 @After77 public void tearDown() throws Exception {78 driver.quit();79 }80 private void populate() {81 //populate text fields with two random number82 List<WebElement> elems = driver.findElements(By.tagName("EditText"));83 Random random = new Random();84 for (WebElement elem : elems) {85 int rndNum = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;86 elem.sendKeys(String.valueOf(rndNum));87 values.add(rndNum);88 }89 }90 @Test91 public void testUIComputation() throws Exception {92 // populate text fields with values93 populate();94 // trigger computation by using the button95 WebElement button = driver.findElement(By.tagName("Button"));96 button.click();97 // is sum equal ?98 WebElement texts = driver.findElement(By.tagName("text"));99 assertEquals(texts.getText(), String.valueOf(values.get(0) + values.get(1)));100 }101 @Test102 public void testActive() throws Exception {103 WebElement text = driver.findElement(By.xpath("//textfield[1]"));104 assertTrue(text.isDisplayed());105 WebElement button = driver.findElement(By.xpath("//button[1]"));106 assertTrue(button.isDisplayed());107 }108 @Test109 public void testBasicAlert() throws Exception {110 driver.findElement(By.xpath("//button[2]")).click();111//112// Alert alert = driver.switchTo().alert();113//114// alert.accept();115 WebElement acceptButton = driver.findElement(By.xpath("//button[1]"));116 acceptButton.click();117 }118// @Test119// public void testBasicTagName() throws Exception {120// WebElement text = driver.findElement(By.xpath("//text[2]"));121// assertEquals(text.getTagName(), "UIATextField");122// }123 @Test124 public void testBasicButton() throws Exception {125 WebElement button = driver.findElement(By.xpath("//button[1]"));126 assertEquals(button.getText(), "Compute Sum");127 }128 @Test129 public void testClear() throws Exception {130 WebElement text = driver.findElement(By.xpath("//textfield[1]"));131 text.sendKeys("12");132 text.clear();133 assertEquals(text.getText(), "");134 }135// @Test136// public void testHideKeyboard() throws Exception {137// driver.findElement(By.xpath("//textfield[1]")).sendKeys("12");138//139// WebElement button = driver.findElement(By.name("Done"));140// assertTrue(button.isDisplayed());141//142// button.click();143// }144 @Test145 public void testFindElementByTagName() throws Exception {146 Random random = new Random();147 WebElement text = driver.findElement(By.tagName("textfield"));148 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;149 text.sendKeys(String.valueOf(number));150 driver.findElement(By.tagName("button")).click();151 // is sum equal ?152 WebElement sumLabel = driver.findElement(By.tagName("text"));153 assertEquals(sumLabel.getText(), String.valueOf(number));154 }155 @Test156 public void testFindElementsByTagName() throws Exception {157 Random random = new Random();158 WebElement text = driver.findElements(By.tagName("textfield")).get(1);159 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;160 text.sendKeys(String.valueOf(number));161 driver.findElements(By.tagName("button")).get(0).click();162 // is sum equal ?163 WebElement texts = driver.findElements(By.tagName("text")).get(0);164 assertEquals(texts.getText(), String.valueOf(number));165 }166 @Test167 public void testFindElementByName() throws Exception {168 Random random = new Random();169 WebElement text = driver.findElement(By.name("TextField1"));170 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;171 text.sendKeys(String.valueOf(number));172 // is sum equal ?173 WebElement sumLabel = driver.findElement(By.name("SumLabel"));174 driver.findElement(By.name("ComputeSumButton")).click();175 assertEquals(sumLabel.getText(), String.valueOf(number));176 }177 @Test178 public void testFindElementsByName() throws Exception {179 Random random = new Random();180 WebElement text = driver.findElements(By.name("TextField1")).get(0);181 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;182 text.sendKeys(String.valueOf(number));183 // is sum equal ?184 WebElement sumLabel = driver.findElements(By.name("SumLabel")).get(0);185 driver.findElements(By.name("ComputeSumButton")).get(0).click();186 assertEquals(sumLabel.getText(), String.valueOf(number));187 }188 @Test189 public void testFindElementByXpath() throws Exception {190 Random random = new Random();191 WebElement text = driver.findElement(By.xpath("//textfield[1]"));192 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;193 text.sendKeys(String.valueOf(number));194 // is sum equal ?195 driver.findElement(By.xpath("//button[1]")).click();196 WebElement sumLabel = driver.findElement(By.xpath("//text[1]"));197 assertEquals(sumLabel.getText(), String.valueOf(number));198 }199 @Test200 public void testFindElementsByXpath() throws Exception {201 Random random = new Random();202 WebElement text = driver.findElements(By.xpath("//textfield")).get(1);203 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;204 text.sendKeys(String.valueOf(number));205 // is sum equal ?206 driver.findElements(By.xpath("//button")).get(0).click();207 WebElement sumLabel = driver.findElements(By.xpath("//text")).get(0);208 assertEquals(sumLabel.getText(), String.valueOf(number));209 }210 @Test211 public void testAttribute() throws Exception {212 Random random = new Random();213 WebElement text = driver.findElement(By.xpath("//textfield[1]"));214 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;215 text.sendKeys(String.valueOf(number));216 assertEquals(text.getAttribute("name"), "TextField1");217// assertEquals(text.getAttribute("label"), "TextField1");218 assertEquals(text.getAttribute("text"), String.valueOf(number));219 }220 @Test221 public void testSlider() throws Exception {222 //get the slider223 WebElement slider = driver.findElement(By.xpath("//seek[1]"));224// assertEquals(slider.getAttribute("value"), "50%");225 TouchActions drag = new TouchActions(driver).flick(slider, new Integer(-1), 0, 0);226// drag.perform();227// assertEquals(slider.getAttribute("value"), "0%");228 }229 @Test230 public void testLocation() throws Exception {231 WebElement button = driver.findElement(By.xpath("//button[1]"));232 Point location = button.getLocation();233 assertEquals(location.getX(), 157);234 assertEquals(location.getY(), 182);235 }236 @Test237 public void testSessions() throws Exception {238 HttpGet request = new HttpGet("http://localhost:4723/wd/hub/sessions");239 DefaultHttpClient httpClient = new DefaultHttpClient();240 HttpResponse response = httpClient.execute(request);241 HttpEntity entity = response.getEntity();242 JSONObject jsonObject = (JSONObject) new JSONParser().parse(EntityUtils.toString(entity));243 String sessionId = ((RemoteWebDriver) driver).getSessionId().toString();244 assertEquals(sessionId, jsonObject.get("sessionId"));245 httpClient.close();246 }247// @Test248// public void testSize() {249// Dimension text1 = driver.findElement(By.xpath("//textfield[1]")).getSize();250// Dimension text2 = driver.findElement(By.xpath("//textfield[2]")).getSize();251// assertEquals(text1.getWidth(), text2.getWidth());252// assertEquals(text1.getHeight(), text2.getHeight());253// }254 public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {255 private RemoteTouchScreen touch;256 public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {257 super(remoteAddress, desiredCapabilities);258 touch = new RemoteTouchScreen(getExecuteMethod());259 }260 public TouchScreen getTouch() {261 return touch;262 }263 }264}...

Full Screen

Full Screen

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 License20 * along with this program. If not, see <http://www.gnu.org/licenses/>.21 */22package com.sugarcrm.candybean.examples.mobile;23import org.junit.*;24import org.json.simple.JSONObject;25import org.json.simple.parser.JSONParser;26import org.apache.http.util.EntityUtils;27import org.apache.http.HttpEntity;28import org.apache.http.HttpResponse;29import org.apache.http.client.methods.HttpGet;30import org.apache.http.impl.client.DefaultHttpClient;31import org.openqa.selenium.Dimension;32import org.openqa.selenium.Alert;33import org.openqa.selenium.By;34import org.openqa.selenium.WebDriver;35import org.openqa.selenium.WebElement;36import org.openqa.selenium.Point;37import org.openqa.selenium.interactions.HasTouchScreen;38import org.openqa.selenium.Capabilities;39import org.openqa.selenium.interactions.TouchScreen;40import org.openqa.selenium.remote.CapabilityType;41import org.openqa.selenium.remote.DesiredCapabilities;42import org.openqa.selenium.remote.RemoteWebDriver;43import org.openqa.selenium.remote.RemoteTouchScreen;44import org.openqa.selenium.interactions.touch.TouchActions;45import java.net.URL;46import java.util.ArrayList;47import java.util.List;48import java.util.Random;49import static org.junit.Assert.assertEquals;50import static org.junit.Assert.assertTrue;51/**52 * Simple <a href="https://github.com/appium/appium">Appium</a> test which runs against an appium server deployed53 * with the 'TestApp' iPhone project which is included in the Appium source distribution.54 *55 * @author Larry Cao56 */57public class AppiumIosTest {58 private static WebDriver driver;59 private static List<Integer> values;60 private static final int MINIMUM = 0;61 private static final int MAXIMUM = 10;62 @Before63 public void setUp() throws Exception {64 // set up appium65 DesiredCapabilities capabilities = new DesiredCapabilities();66 capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS");67 capabilities.setCapability(CapabilityType.VERSION, "6.0");68 capabilities.setCapability(CapabilityType.PLATFORM, "Mac");69 capabilities.setCapability("app", "https://s3.amazonaws.com/voodoo2/TestApp.zip");70 URL remoteAddress = new URL("http://127.0.0.1:4723/wd/hub");71 driver = new SwipeableWebDriver(remoteAddress, capabilities);72 values = new ArrayList<>();73 }74 @After75 public void tearDown() throws Exception {76 driver.quit();77 }78 private void populate() {79 //populate text fields with two random number80 List<WebElement> elems = driver.findElements(By.tagName("textField"));81 Random random = new Random();82 for (WebElement elem : elems) {83 int rndNum = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;84 elem.sendKeys(String.valueOf(rndNum));85 values.add(rndNum);86 }87 }88 @Test89 public void testUIComputation() throws Exception {90 // populate text fields with values91 populate();92 // trigger computation by using the button93 WebElement button = driver.findElement(By.tagName("button"));94 button.click();95 // is sum equal ?96 WebElement texts = driver.findElement(By.tagName("staticText"));97 assertEquals(texts.getText(), String.valueOf(values.get(0) + values.get(1)));98 }99 @Test100 public void testActive() throws Exception {101 WebElement text = driver.findElement(By.xpath("//textfield[1]"));102 assertTrue(text.isDisplayed());103 WebElement button = driver.findElement(By.xpath("//button[1]"));104 assertTrue(button.isDisplayed());105 }106 @Test107 public void testBasicAlert() throws Exception {108 driver.findElement(By.xpath("//button[2]")).click();109 Alert alert = driver.switchTo().alert();110 //check if title of alert is correct111 assertEquals(alert.getText(), "Cool title");112 //Appium alert.accept() not yet supported in iOS7 yet. https://github.com/appium/appium/issues/994113// alert.accept();114 }115 @Test116 public void testBasicTagName() throws Exception {117 WebElement text = driver.findElement(By.xpath("//textfield[1]"));118 assertEquals(text.getTagName(), "UIATextField");119 }120 @Test121 public void testBasicButton() throws Exception {122 WebElement button = driver.findElement(By.xpath("//button[1]"));123 assertEquals(button.getText(), "ComputeSumButton");124 }125 @Test126 public void testClear() throws Exception {127 WebElement text = driver.findElement(By.xpath("//textfield[1]"));128 text.sendKeys("12");129 text.clear();130 assertEquals(text.getText(), "");131 }132 @Test133 public void testHideKeyboard() throws Exception {134 driver.findElement(By.xpath("//textfield[1]")).sendKeys("12");135 WebElement button = driver.findElement(By.name("Done"));136 assertTrue(button.isDisplayed());137 button.click();138 }139 @Test140 public void testFindElementByTagName() throws Exception {141 Random random = new Random();142 WebElement text = driver.findElement(By.tagName("textField"));143 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;144 text.sendKeys(String.valueOf(number));145 driver.findElement(By.tagName("button")).click();146 // is sum equal ?147 WebElement sumLabel = driver.findElement(By.tagName("staticText"));148 assertEquals(sumLabel.getText(), String.valueOf(number));149 }150 @Test151 public void testFindElementsByTagName() throws Exception {152 Random random = new Random();153 WebElement text = driver.findElements(By.tagName("textField")).get(1);154 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;155 text.sendKeys(String.valueOf(number));156 driver.findElements(By.tagName("button")).get(0).click();157 // is sum equal ?158 WebElement texts = driver.findElements(By.tagName("staticText")).get(0);159 assertEquals(texts.getText(), String.valueOf(number));160 }161 @Test162 public void testFindElementByName() throws Exception {163 Random random = new Random();164 WebElement text = driver.findElement(By.name("TextField1"));165 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;166 text.sendKeys(String.valueOf(number));167 // is sum equal ?168 WebElement sumLabel = driver.findElement(By.name("SumLabel"));169 driver.findElement(By.name("ComputeSumButton")).click();170 assertEquals(sumLabel.getText(), String.valueOf(number));171 }172 @Test173 public void testFindElementsByName() throws Exception {174 Random random = new Random();175 WebElement text = driver.findElements(By.name("TextField1")).get(0);176 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;177 text.sendKeys(String.valueOf(number));178 // is sum equal ?179 WebElement sumLabel = driver.findElements(By.name("SumLabel")).get(0);180 driver.findElements(By.name("ComputeSumButton")).get(0).click();181 assertEquals(sumLabel.getText(), String.valueOf(number));182 }183 @Test184 public void testFindElementByXpath() throws Exception {185 Random random = new Random();186 WebElement text = driver.findElement(By.xpath("//textfield[1]"));187 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;188 text.sendKeys(String.valueOf(number));189 // is sum equal ?190 driver.findElement(By.xpath("//button[1]")).click();191 WebElement sumLabel = driver.findElement(By.xpath("//text[1]"));192 assertEquals(sumLabel.getText(), String.valueOf(number));193 }194 @Test195 public void testFindElementsByXpath() throws Exception {196 Random random = new Random();197 WebElement text = driver.findElements(By.xpath("//textfield")).get(1);198 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;199 text.sendKeys(String.valueOf(number));200 // is sum equal ?201 driver.findElements(By.xpath("//button")).get(0).click();202 WebElement sumLabel = driver.findElements(By.xpath("//text")).get(0);203 assertEquals(sumLabel.getText(), String.valueOf(number));204 }205 @Test206 public void testAttribute() throws Exception {207 Random random = new Random();208 WebElement text = driver.findElement(By.xpath("//textfield[1]"));209 int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;210 text.sendKeys(String.valueOf(number));211 assertEquals(text.getAttribute("name"), "TextField1");212 assertEquals(text.getAttribute("label"), "TextField1");213 assertEquals(text.getAttribute("value"), String.valueOf(number));214 }215 @Test216 public void testSlider() throws Exception {217 //get the slider218 WebElement slider = driver.findElement(By.xpath("//slider[1]"));219 assertEquals(slider.getAttribute("value"), "50%");220 TouchActions drag = new TouchActions(driver).flick(slider, new Integer(-1), 0, 0);221 drag.perform();222 assertEquals(slider.getAttribute("value"), "0%");223 }224 @Test225 public void testLocation() throws Exception {226 WebElement button = driver.findElement(By.xpath("//button[1]"));227 Point location = button.getLocation();228 assertEquals(location.getX(), 94);229 assertEquals(location.getY(), 122);230 }231 @Test232 public void testSessions() throws Exception {233 HttpGet request = new HttpGet("http://localhost:4723/wd/hub/sessions");234 DefaultHttpClient httpClient = new DefaultHttpClient();235 HttpResponse response = httpClient.execute(request);236 HttpEntity entity = response.getEntity();237 JSONObject jsonObject = (JSONObject) new JSONParser().parse(EntityUtils.toString(entity));238 String sessionId = ((RemoteWebDriver) driver).getSessionId().toString();239 assertEquals(sessionId, jsonObject.get("sessionId"));240 httpClient.close();241 }242 @Test243 public void testSize() {244 Dimension text1 = driver.findElement(By.xpath("//textfield[1]")).getSize();245 Dimension text2 = driver.findElement(By.xpath("//textfield[2]")).getSize();246 assertEquals(text1.getWidth(), text2.getWidth());247 assertEquals(text1.getHeight(), text2.getHeight());248 }249 public static class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {250 private RemoteTouchScreen touch;251 public SwipeableWebDriver(URL remoteAddress, 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

...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 License20 * along with this program. If not, see <http://www.gnu.org/licenses/>.21 */22package com.sugarcrm.candybean.examples.mobile;23import org.junit.*;24import org.openqa.selenium.By;25import org.openqa.selenium.WebDriver;26import org.openqa.selenium.WebElement;27import org.openqa.selenium.interactions.HasTouchScreen;28import org.openqa.selenium.Capabilities;29import org.openqa.selenium.interactions.TouchScreen;30import org.openqa.selenium.remote.CapabilityType;31import org.openqa.selenium.remote.DesiredCapabilities;32import org.openqa.selenium.remote.RemoteWebDriver;33import org.openqa.selenium.remote.RemoteTouchScreen;34import java.net.URL;35import java.util.ArrayList;36import java.util.List;37import java.util.Set;38import java.util.concurrent.TimeUnit;39import static org.junit.Assert.assertTrue;40/**41 * Simple <a href="https://github.com/appium/appium">Appium</a> test which runs against an Appium server deployed42 * with the Sugar Mobile android app.43 *44 * @author Larry Cao45 */46public class SugarAndroidTest {47 private WebDriver driver;48 private List<Integer> values;49 private static final int MINIMUM = 0;50 private static final int MAXIMUM = 10;51 @Before52 public void setUp() throws Exception {53 // set up appium54 DesiredCapabilities capabilities = new DesiredCapabilities();55 capabilities.setCapability(CapabilityType.BROWSER_NAME, "Selendroid");56 capabilities.setCapability(CapabilityType.VERSION, "4.2.2");57 capabilities.setCapability("device", "Android");58 capabilities.setCapability(CapabilityType.PLATFORM, "Mac");59 capabilities.setCapability("app", "https://s3.amazonaws.com/voodoo2/SugarCRM.apk.zip");60 capabilities.setCapability("app-package", "com.sugarcrm.nomad");61 capabilities.setCapability("app-activity", "NomadActivity");62 driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);63 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);64 values = new ArrayList<>();65 }66 @After67 public void tearDown() throws Exception {68 driver.quit();69 }70 @Test71 public void testLogin() throws Exception {72 WebElement username = driver.findElement(By.xpath("//window[1]/scrollview[1]/webview[1]/textfield[1]"));73 assertTrue(username.isDisplayed());74 Set<String> handles = driver.getWindowHandles();75 for (String s : handles) {76 System.out.println(s);77 }78 if (!username.getText().equals("")) {79 username.clear();80 }81 username.sendKeys("admin");82 WebElement password = driver.findElement(By.xpath("//window[1]/scrollview[1]/webview[1]/secure[1]"));83 assertTrue(password.isDisplayed());84 password.click();85 password.sendKeys("asdf");86 WebElement login = driver.findElement(By.xpath("//window[1]/scrollview[1]/webview[1]/link[1]"));87 login.click();88 Thread.sleep(1000000);89 }90 public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {91 private RemoteTouchScreen touch;92 public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {93 super(remoteAddress, desiredCapabilities);94 touch = new RemoteTouchScreen(getExecuteMethod());95 }96 public TouchScreen getTouch() {97 return touch;98 }99 }100}...

Full Screen

Full Screen

Source:CallingCardTest.java Github

copy

Full Screen

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

...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);40 }41 42 public void scroll(Coordinates where, int xOffset, int yOffset) {43 Map<String, Object> scrollParams = CoordinatesUtils.paramsFromCoordinates(where);44 scrollParams.put("xoffset", Integer.valueOf(xOffset));45 scrollParams.put("yoffset", Integer.valueOf(yOffset));46 executeMethod.execute("touchScroll", scrollParams);...

Full Screen

Full Screen

Source:AppiumTest.java Github

copy

Full Screen

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

Source:HotelSearchTests.java Github

copy

Full Screen

...20import com.merlini.app.page.Navi;21import com.merlini.common.BaseCase;22public class HotelSearchTests extends BaseCase{23 @Test(description="验证品牌")24 public void HotelPPTest() throws InterruptedException {25 HomePage homePage=new HomePage(driver);26 homePage.SwitchTo(Navi.Hotel);27 HotelHomePage hotelHomePage =new HotelHomePage(driver);28 List<String> pplist=new ArrayList<String>();29 //pplist.add("");30 hotelHomePage.checkPP();31 //Thread.sleep(300000);32 //hotelHomePage.setDate();33 }34 @Test(enabled=false)35 public void HotelCityTest() throws InterruptedException {36 //Thread.sleep(10000);37// RemoteTouchScreen rts = new RemoteTouchScreen();38// driver.swipe(startx, starty, endx, endy, duration);39 //40 //driver.41 HomePage homePage=new HomePage(driver);42 homePage.SwitchTo(Navi.Hotel);43 HotelHomePage hotelHomePage =new HotelHomePage(driver);44 hotelHomePage.checkCity("上海");45 //Thread.sleep(300000);46 //hotelHomePage.setDate();47 }48 @Test(enabled=false)49 public void HotelSearchTest() {...

Full Screen

Full Screen

up

Using AI Code Generation

copy

Full Screen

1import java.net.MalformedURLException;2import java.net.URL;3import org.openqa.selenium.By;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.remote.DesiredCapabilities;7import org.openqa.selenium.remote.RemoteTouchScreen;8import org.openqa.selenium.remote.RemoteWebDriver;9public class ScrollDown {10public static void main(String[] args) throws MalformedURLException, InterruptedException {11 DesiredCapabilities capabilities = new DesiredCapabilities();12 capabilities.setCapability("deviceName", "Android");13 capabilities.setCapability("platformVersion", "4.4.4");14 capabilities.setCapability("platformName", "Android");15 capabilities.setCapability("appPackage", "com.android.chrome");16 capabilities.setCapability("appActivity", "com.google.android.apps.chrome.Main");

Full Screen

Full Screen

up

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.RemoteTouchScreen;2import org.openqa.selenium.remote.RemoteWebElement;3import org.openqa.selenium.remote.RemoteWebDriver;4RemoteTouchScreen touchScreen = new RemoteTouchScreen((RemoteWebDriver)driver);5touchScreen.up(10, 10);6import org.openqa.selenium.remote.RemoteTouchScreen;7import org.openqa.selenium.remote.RemoteWebElement;8import org.openqa.selenium.remote.RemoteWebDriver;9RemoteTouchScreen touchScreen = new RemoteTouchScreen((RemoteWebDriver)driver);10touchScreen.down(10, 10);11import org.openqa.selenium.remote.RemoteTouchScreen;12import org.openqa.selenium.remote.RemoteWebElement;13import org.openqa.selenium.remote.RemoteWebDriver;14RemoteTouchScreen touchScreen = new RemoteTouchScreen((RemoteWebDriver)driver);15touchScreen.move(10, 10);16import org.openqa.selenium.remote.RemoteTouchScreen;17import org.openqa.selenium.remote.RemoteWebElement;18import org.openqa.selenium.remote.RemoteWebDriver;19RemoteTouchScreen touchScreen = new RemoteTouchScreen((RemoteWebDriver)driver);20touchScreen.scroll(10, 10);21import org.openqa.selenium.remote.RemoteTouchScreen;22import org.openqa.selenium.remote.RemoteWebElement;23import org.openqa.selenium.remote.RemoteWebDriver;24RemoteTouchScreen touchScreen = new RemoteTouchScreen((RemoteWebDriver)driver);25touchScreen.singleTap(10, 10);26import org.openqa.selenium.remote.RemoteTouchScreen;27import org.openqa.selenium.remote.RemoteWebElement;28import org.openqa.selenium.remote.RemoteWebDriver;29RemoteTouchScreen touchScreen = new RemoteTouchScreen((RemoteWebDriver)driver);30touchScreen.doubleTap(10, 10);31import org.openqa.selenium.remote.RemoteTouchScreen;32import org.openqa.selenium.remote.RemoteWebElement;33import org.openqa.selenium.remote.RemoteWebDriver;34RemoteTouchScreen touchScreen = new RemoteTouchScreen((RemoteWebDriver)driver);35touchScreen.longPress(10, 10);36import org.openqa.selenium.remote.RemoteTouchScreen;37import org.openqa.selenium.remote.RemoteWebElement;38import org.openqa.selenium.remote.RemoteWebDriver;

Full Screen

Full Screen

up

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriver;2import org.openqa.selenium.WebElement;3import org.openqa.selenium.remote.RemoteTouchScreen;4import org.openqa.selenium.remote.RemoteWebElement;5import org.openqa.selenium.remote.RemoteWebDriver;6import org.openqa.selenium.remote.DesiredCapabilities;7import org.openqa.selenium.remote.CapabilityType;8import org.openqa.selenium.remote.RemoteWebElement;9import org.openqa.selenium.remote.RemoteTouchScreen;10import org.openqa.selenium.remote.RemoteWebDriver;11import org.openqa.selenium.remote.DesiredCapabilities;12import org.openqa.selenium.remote.CapabilityType;13import org.openqa.selenium.Point;14import org.openqa.selenium.Dimension;15import org.openqa.selenium.By;16import org.openqa.selenium.JavascriptExecutor;17import org.openqa.selenium.interactions.touch.TouchActions;18import org.openqa.selenium.support.ui.ExpectedConditions;19import org.openqa.selenium.support.ui.WebDriverWait;20import org.openqa.selenium.support.ui.ExpectedCondition;21import org.openqa.selenium.support.ui.FluentWait;22import org.openqa.selenium.support.ui.Wait;23import org.openqa.selenium.support.ui.Sleeper;24import org.openqa.selenium.support.ui.Select;25import org.openqa.selenium.support.ui.LoadableComponent;26import org.openqa.selenium.support.ui.WebDriverWait;27import org.openqa.selenium.support.ui.ExpectedCondition;28import org.openqa.selenium.support.ui.FluentWait;29import org.openqa.selenium.support.ui.Wait;30import org.openqa.selenium.support.ui.Sleeper;31import org.openqa.selenium.support.ui.Select;32import org.openqa.selenium.support.ui.LoadableComponent;33import org.openqa.selenium.support.ui.WebDriverWait;34import org.openqa.selenium.support.ui.ExpectedCondition;35import org.openqa.selenium.support.ui.FluentWait;36import org.openqa.selenium.support.ui.Wait;37import org.openqa.selenium.support.ui.Sleeper;38import org.openqa.selenium.support.ui.Select;39import org.openqa.selenium.support.ui.LoadableComponent;40import org.openqa.selenium.support.ui.WebDriverWait;41import org.openqa.selenium.support.ui.ExpectedCondition;42import org.openqa.selenium.support.ui.FluentWait;43import org.openqa.selenium.support.ui.Wait;44import org.openqa.selenium.support.ui.Sleeper;45import org.openqa.selenium.support.ui.Select;46import org.openqa.selenium.support.ui.LoadableComponent;47import org.openqa.selenium.support.ui.WebDriverWait;48import org.openqa.selenium.support.ui.ExpectedCondition;49import org.openqa.selenium.support.ui.FluentWait;50import org.openqa.selenium.support.ui.Wait;51import org.openqa.selenium.support.ui.Sleeper;52import org.openqa.selenium.support.ui.Select;53import org.openqa.selenium.support.ui.LoadableComponent;54import org.openqa.selenium.support.ui.WebDriverWait;55import org.openqa.selenium.support.ui.ExpectedCondition

Full Screen

Full Screen

up

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.RemoteTouchScreen;2import org.openqa.selenium.remote.RemoteWebDriver;3import org.openqa.selenium.Dimension;4import org.openqa.selenium.Point;5RemoteWebDriver driver = new RemoteWebDriver();6RemoteTouchScreen touch = new RemoteTouchScreen(driver);7Dimension size = driver.manage().window().getSize();8int width = size.getWidth();9int height = size.getHeight();10int x = width/2;11int y = height/2;12touch.scroll(x, y, x, y/2);13import org.openqa.selenium.remote.RemoteTouchScreen;14import org.openqa.selenium.remote.RemoteWebDriver;15import org.openqa.selenium.Dimension;16import org.openqa.selenium.Point;17RemoteWebDriver driver = new RemoteWebDriver();18RemoteTouchScreen touch = new RemoteTouchScreen(driver);19Dimension size = driver.manage().window().getSize();20int width = size.getWidth();21int height = size.getHeight();22int x = width/2;23int y = height/2;24touch.scroll(x, y, x, y*2);25import org.openqa.selenium.remote.RemoteTouchScreen;26import org.openqa.selenium.remote.RemoteWebDriver;27import org.openqa.selenium.Dimension;28import org.openqa.selenium.Point;29RemoteWebDriver driver = new RemoteWebDriver();30RemoteTouchScreen touch = new RemoteTouchScreen(driver);31Dimension size = driver.manage().window().getSize();32int width = size.getWidth();33int height = size.getHeight();34int x = width/2;35int y = height/2;36touch.scroll(x, y, x/2, y);37import org.openqa.selenium.remote.RemoteTouchScreen;38import org.openqa.selenium.remote.RemoteWebDriver;39import org.openqa.selenium.Dimension;40import org.openqa.selenium.Point;41RemoteWebDriver driver = new RemoteWebDriver();42RemoteTouchScreen touch = new RemoteTouchScreen(driver);43Dimension size = driver.manage().window().getSize();44int width = size.getWidth();45int height = size.getHeight();46int x = width/2;47int y = height/2;48touch.scroll(x, y, x*2, y);49import

Full Screen

Full Screen

up

Using AI Code Generation

copy

Full Screen

1package com.example.android.testing.uiautomator.BasicSample;2import android.graphics.Point;3import android.graphics.Rect;4import android.os.RemoteException;5import android.support.test.uiautomator.UiDevice;6import android.support.test.uiautomator.UiObject;7import android.support.test.uiautomator.UiObjectNotFoundException;8import android.support.test.uiautomator.UiSelector;9import android.support.test.uiautomator.UiScrollable;10import android.support.test.uiautomator.UiWatcher;11import android.util.Log;12import org.junit.Before;13import org.junit.Test;14import java.io.IOException;15import static android.support.test.InstrumentationRegistry.getInstrumentation;16import static org.junit.Assert.assertTrue;17public class SwipeUp {18 = "com.example.android.testing.uiautomator.BasicSample";19 private static final int LAUNCH_TIMEOUT = 5000;20 private static final String STRING_TO_BE_TYPED = "UiAutomator";21 private UiDevice mDevice;22 public void startMainActivityFromHomeScreen() throws UiObjectNotFoundException {23 mDevice = UiDevice.getInstance(getInstrumentation());24 mDevice.pressHome();25 final String launcherPackage = mDevice.getLauncherPackageName();26 mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)),27 LAUNCH_TIMEOUT);28 Context context = getInstrumentation().getContext();29 final Intent intent = context.getPackageManager()30 .getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE);31 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);32 context.startActivity(intent);33 mDevice.wait(Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)),34 LAUNCH_TIMEOUT);35 }36 public void testChangeText_sameActivity() throws UiObjectNotFoundException, IOException {37 mDevice = UiDevice.getInstance(getInstrumentation());38 int height = mDevice.getDisplayHeight();39 int width = mDevice.getDisplayWidth();40 int start_x = width / 2;

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