List of usage examples for org.openqa.selenium WebElement getLocation
Point getLocation();
From source file:com.checkAuto.appium.screens.nativeapp.makemytrip.CopyOfGenerate_orders.java
public void into() throws InterruptedException { Thread.sleep(3000);//from w w w .j a v a2 s . c o m login_button.click(); Thread.sleep(5000); new_add_detection.click(); // Thread.sleep(5000); // index1.click(); // choose_confirm.click(); /*edit_search.sendKeys("?"); search_button.click(); search_index1.click(); confirm_yes.click();*/ // ? ? basic_info.click(); /*car_num_area_list.click(); car_num_area_list_index.click(); car_num.sendKeys("LYN100"); // car_type_box.click(); car_type.click(); // car_publiser_.click(); //? firsthand_n.click(); // transfer_user_y.click(); // transfer_date.click(); confirm_yes.click(); // transfer_times_input.click(); transfer_times.click(); // using_nature_.click(); using_nature_index.click(); //VIN vin_code_.sendKeys("LYW091"); // models_cars.click(); models_cars_1.click(); models_cars_1_2.click(); models_cars_1_2_3.click(); //? guobiao_num.sendKeys("LYW000001"); Thread.sleep(2000);*/ //? // driver.scrollTo(""); int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; driver.swipe(width / 2, height * 6 / 10, width / 2, height / 10, 1000); // Thread.sleep(2000); // /* production_date.click(); confirm_yes.click(); //?? engine_num.sendKeys("LYW0000001"); // register_date.click(); confirm_yes.click(); // jiaoqiangxian_n.click(); // commercial_insurance_n.click(); // nianjian_n.click(); // travel_tax_n.click();*/ driver.swipe(width / 2, height * 6 / 10, width / 2, height / 10, 1000); // car_inventory_input.click(); /*car_inventory_province.click(); car_inventory_province_index.click(); car_inventory_city.click(); car_inventory_city_index.click(); confirm_yes.click();*/ WebElement ee = driver.findElementById("com.youxinpai.checkauto.act:id/sd_sidebar"); //?left,top Point p1 = ee.getLocation(); //? int w1 = ee.getSize().width; //? int h1 = ee.getSize().height; //bounds ?p1.x, p1.y?p1.x+w1, p1.y+h1 //Rect r = new Rect(p1.x, p1.y, p1.x+w1, p1.y+h1); //Rect r = new Rect(int left, int top, int right, int bottom) UIAUTOMATOR? // bottom-top int h2 = p1.y + h1 - p1.y; //22?22?? int h3 = h2 / 22; // X?? // public final float exactCenterX() { // return (left + right) * 0.5f; // } //Y?? // public final int centerY() { // return (top + bottom) >> 1; // } //x???? int x = (p1.x + p1.x + w1) >> 1; //Y??top + bottom //????? int y = 0; for (int n = 0; n < 22; n++) { y = ((p1.y + (n * h3)) + (p1.y + h1 - ((22 - n) * h3))) >> 1; driver.tap(1, x, y, 500); } driver.tap(1, x, y, 500); // driver.tap(1, x,y,500); // // driver.tap(1, x,y,500); // System.out.println(ee.getText()); // System.out.println(ee.getAttribute("index")); System.out.println("------"); /* Point p=ee.getLocation(); System.out.println(p.x); System.out.println(p.y); Thread.sleep(10000); ee.click();*/ Thread.sleep(15000); TouchAction act = new TouchAction(driver); act.longPress(1035, 251).moveTo(1035, 1873).release().perform(); // WebElement datePicker= driver.findElement(By.name("Date Picker")); // WebElement steppers= driver.findElement(By.name("Steppers")); int startY = ee.getLocation().y; int endY = ee.getLocation().y; System.out.println(startY + " -- " + endY); Thread.sleep(10000); //act.press(datePicker, 30, 10).release().perform(); //act.press(150, startY).moveTo(150, endY).release().perform(); //act.press(ee, 30, 10).moveTo(act).release().perform(); // ee. // obj = deriver.findByid("A"); // Rect r = obj.getBounds(); // // // int h = r.height(); // // //? // int h1 = h/22; // // // ?? // Rect r1 = new Rect(1062,225+(2*h1),1152,1776-((22-2)*h1)); // device.click(r1.centerX(),r1.centerY()); // choose_car_color.click(); choose_white_color.click(); // fuel_type.click(); choose_electric.click(); /*int w = driver.manage().window().getSize().width; int h = driver.manage().window().getSize().height; driver.swipe(w/2, h*6/10, w/2, h/10, 1000);*/ displacement1.click(); displacement1_index.click(); displacement2.click(); displacement2_index.click(); // driver.scrollTo("??"); // car_key.click(); //2 car_key_2.click(); save_info.click(); // // // // // // // // // // // // // using_nature_box.click(); // using_nature.click(); }
From source file:com.checkAuto.appium.screens.nativeapp.makemytrip.Copy_2_of_Generate_orders.java
public void into() throws InterruptedException { Thread.sleep(3000);//from w ww . j a va2 s .co m login_button.click(); Thread.sleep(5000); new_add_detection.click(); // Thread.sleep(5000); // index1.click(); // choose_confirm.click(); /*edit_search.sendKeys("?"); search_button.click(); search_index1.click(); confirm_yes.click();*/ // ? ? basic_info.click(); /*car_num_area_list.click(); car_num_area_list_index.click(); car_num.sendKeys("LYN100"); // car_type_box.click(); car_type.click(); // car_publiser_.click(); //? firsthand_n.click(); // transfer_user_y.click(); // transfer_date.click(); confirm_yes.click(); // transfer_times_input.click(); transfer_times.click(); // using_nature_.click(); using_nature_index.click(); //VIN vin_code_.sendKeys("LYW091"); // models_cars.click(); models_cars_1.click(); models_cars_1_2.click(); models_cars_1_2_3.click(); //? guobiao_num.sendKeys("LYW000001"); Thread.sleep(2000);*/ //? // driver.scrollTo(""); int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; driver.swipe(width / 2, height * 6 / 10, width / 2, height / 10, 1000); // Thread.sleep(2000); // /* production_date.click(); confirm_yes.click(); //?? engine_num.sendKeys("LYW0000001"); // register_date.click(); confirm_yes.click(); // jiaoqiangxian_n.click(); // commercial_insurance_n.click(); // nianjian_n.click(); // travel_tax_n.click();*/ driver.swipe(width / 2, height * 6 / 10, width / 2, height / 10, 1000); // car_inventory_input.click(); /*car_inventory_province.click(); car_inventory_province_index.click(); car_inventory_city.click(); car_inventory_city_index.click(); confirm_yes.click();*/ WebElement ee = driver.findElementById("com.youxinpai.checkauto.act:id/sd_sidebar"); //?left,top Point p1 = ee.getLocation(); //? int w1 = ee.getSize().width; //? int h1 = ee.getSize().height; //bounds ?p1.x, p1.y?p1.x+w1, p1.y+h1 //Rect r = new Rect(p1.x, p1.y, p1.x+w1, p1.y+h1); //Rect r = new Rect(int left, int top, int right, int bottom) UIAUTOMATOR? // bottom-top int h2 = p1.y + h1 - p1.y; //22?22?? int h3 = h2 / 22; // X?? // public final float exactCenterX() { // return (left + right) * 0.5f; // } //Y?? // public final int centerY() { // return (top + bottom) >> 1; // } //x???? int x = (p1.x + p1.x + w1) >> 1; //Y??top + bottom //????? int y = 0; for (int n = 0; n < 3; n++) { y = ((p1.y + (n * h3)) + (p1.y + h1 - ((22 - n) * h3))) >> 1; driver.tap(1, x, y, 500); } driver.tap(1, x, y, 500); // driver.tap(1, x,y,500); // // driver.tap(1, x,y,500); // System.out.println(ee.getText()); // System.out.println(ee.getAttribute("index")); System.out.println("------"); /* Point p=ee.getLocation(); System.out.println(p.x); System.out.println(p.y); Thread.sleep(10000); ee.click();*/ Thread.sleep(15000); TouchAction act = new TouchAction(driver); act.longPress(1035, 251).moveTo(1035, 1873).release().perform(); act.longPress(1035, 251).moveTo(1035, 1873).release().perform(); act.longPress(1035, 251).moveTo(1035, 1873).release().perform(); act.longPress(1035, 251).moveTo(1035, 1873).release().perform(); act.longPress(1035, 251).moveTo(1035, 1873).release().perform(); // WebElement datePicker= driver.findElement(By.name("Date Picker")); // WebElement steppers= driver.findElement(By.name("Steppers")); int startY = ee.getLocation().y; int endY = ee.getLocation().y; System.out.println(startY + " -- " + endY); Thread.sleep(10000); //act.press(datePicker, 30, 10).release().perform(); //act.press(150, startY).moveTo(150, endY).release().perform(); //act.press(ee, 30, 10).moveTo(act).release().perform(); // ee. // obj = deriver.findByid("A"); // Rect r = obj.getBounds(); // // // int h = r.height(); // // //? // int h1 = h/22; // // // ?? // Rect r1 = new Rect(1062,225+(2*h1),1152,1776-((22-2)*h1)); // device.click(r1.centerX(),r1.centerY()); // choose_car_color.click(); choose_white_color.click(); // fuel_type.click(); choose_electric.click(); /*int w = driver.manage().window().getSize().width; int h = driver.manage().window().getSize().height; driver.swipe(w/2, h*6/10, w/2, h/10, 1000);*/ displacement1.click(); displacement1_index.click(); displacement2.click(); displacement2_index.click(); // driver.scrollTo("??"); // car_key.click(); //2 car_key_2.click(); save_info.click(); // // // // // // // // // // // // // using_nature_box.click(); // using_nature.click(); }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
/** * This method uses the webDriver object to drag and drop the elements from source to destination using javascript * * @param locator/* w ww . j av a2 s . c o m*/ */ @Override public void dragAndDropAnElementUsingJavascript(String sourceElement, String destinationElement, int timeoutInSeconds) { Actions builder = new Actions(getWebDriver()); WebElement src = findElement(sourceElement, timeoutInSeconds); WebElement des = findElement(destinationElement, timeoutInSeconds); String xto = Integer.toString(src.getLocation().x); String yto = Integer.toString(des.getLocation().y); JavascriptExecutor executor = (JavascriptExecutor) webDriver; String event = "function simulate(f,c,d,e){var b,a=null;for(b in eventMatchers)if(eventMatchers[b].test(c)){a=b;break}if(!a)return!1;document.createEvent?(b=document.createEvent(a),a==\"HTMLEvents\"?b.initEvent(c,!0,!0):b.initMouseEvent(c,!0,!0,document.defaultView,0,d,e,d,e,!1,!1,!1,!1,0,null),f.dispatchEvent(b)):(a=document.createEventObject(),a.detail=0,a.screenX=d,a.screenY=e,a.clientX=d,a.clientY=e,a.ctrlKey=!1,a.altKey=!1,a.shiftKey=!1,a.metaKey=!1,a.button=1,f.fireEvent(\"on\"+c,a));return!0} var eventMatchers={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/}; " + "simulate(arguments[0],\"mousedown\",0,0); simulate(arguments[0],\"mousemove\",arguments[1],arguments[2]); simulate(arguments[0],\"mouseup\",arguments[1],arguments[2]); "; try { src.click(); des.click(); builder.dragAndDrop(src, des); } catch (Exception e) { executor.executeScript(event, src, xto, yto); } }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do tap./*from w ww . j a v a2 s. c om*/ * * @param element the element * @param driver the driver */ public static void doTap(final WebElement element, final WebDriver driver) { Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); Dimension dimesions = element.getSize(); int width = dimesions.width; int height = dimesions.height; final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); // tapObject.put("duration", 0.7); tapObject.put("x", x + width - 2); tapObject.put("y", y + height - 2); js.executeScript("mobile: tap", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do left tap./*from w w w . j a va2 s .co m*/ * * @param element the element * @param driver the driver */ public static void doLeftTap(final WebElement element, final WebDriver driver) { LogUtil.log("Do Left Tap", LogLevel.HIGH); Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); Dimension dimesions = element.getSize(); int height = dimesions.height; final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); x = x + 2; y = y + height + 2; tapObject.put("x", x); tapObject.put("y", y); LogUtil.log("X :" + x, LogLevel.HIGH); LogUtil.log("Y :" + y, LogLevel.HIGH); js.executeScript("mobile: tap", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do middle tap./*from w w w. ja va 2s. c o m*/ * * @param element the element * @param driver the driver */ public static void doMiddleTap(final WebElement element, final WebDriver driver) { LogUtil.log("Do Middle Tap", LogLevel.HIGH); Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); Dimension dimesions = element.getSize(); int width = dimesions.width; int height = dimesions.height; final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); tapObject.put("duration", 0.1); int midX = (int) x + (width / 2); int midY = (int) y + (height / 2); LogUtil.log("midX :" + midX, LogLevel.HIGH); LogUtil.log("midY :" + midY, LogLevel.HIGH); tapObject.put("duration", 0.7); tapObject.put("x", (double) midX); tapObject.put("y", (double) midY); js.executeScript("mobile: tap", tapObject); js.executeScript("mobile: tap", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do exact tap./*from w w w . j av a 2 s.c o m*/ * * @param element the element * @param driver the driver */ public static void doExactTap(final WebElement element, final WebDriver driver) { LogUtil.log("Do Exact Tap", LogLevel.HIGH); final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); tapObject.put("x", x); tapObject.put("y", y); js.executeScript("mobile: tap", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do swipe horizontal.//from w w w. j a va 2 s . c om * * @param element the element * @param driver the driver * @param length the length */ public static void doSwipeHorizontal(final WebElement element, final WebDriver driver, final int length) { Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); LogUtil.log("X :" + element.getLocation().getX(), LogLevel.HIGH); LogUtil.log("Y :" + element.getLocation().getY(), LogLevel.HIGH); LogUtil.log("Length :" + length, LogLevel.HIGH); final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); tapObject.put("duration", 0.7); tapObject.put("startX", x + 5); tapObject.put("startY", y); tapObject.put("endX", x + length); tapObject.put("endY", y); js.executeScript("mobile: swipe", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do swipe page left.// www . j a va 2 s. co m * * @param element the element * @param driver the driver */ public static void doSwipePageLeft(final WebElement element, final WebDriver driver) { // final Point point = element.getLocation(); // double x = point.getX(); // double y = point.getY(); LogUtil.log("X :" + element.getLocation().getX(), LogLevel.HIGH); LogUtil.log("Y :" + element.getLocation().getY(), LogLevel.HIGH); final Dimension dimesions = element.getSize(); //int width = dimesions.width; //int height = dimesions.height; LogUtil.log("width :" + dimesions.width, LogLevel.HIGH); LogUtil.log("hieght:" + dimesions.height, LogLevel.HIGH); final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); tapObject.put("duration", 0.7); tapObject.put("startX", (double) getWindowWidth(driver)); tapObject.put("startY", (double) (getWindowHeight(driver) / 2)); tapObject.put("endX", 0.0); tapObject.put("endY", (double) (getWindowHeight(driver) / 2)); js.executeScript("mobile: swipe", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do swipe page right./*from ww w.ja v a2 s. c o m*/ * * @param element the element * @param driver the driver */ public static void doSwipePageRight(final WebElement element, final WebDriver driver) { Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); LogUtil.log("X :" + element.getLocation().getX(), LogLevel.HIGH); LogUtil.log("Y :" + element.getLocation().getY(), LogLevel.HIGH); Dimension dimesions = element.getSize(); int width = dimesions.width; // int height = dimesions.height; LogUtil.log("width :" + dimesions.width, LogLevel.HIGH); LogUtil.log("hieght:" + dimesions.height, LogLevel.HIGH); final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); tapObject.put("duration", 0.7); tapObject.put("startX", x + width); tapObject.put("startY", y); tapObject.put("endX", x); tapObject.put("endY", y); js.executeScript("mobile: swipe", tapObject); }