How to use getCoordinates method of org.cerberus.service.appium.impl.AppiumService class

Best Cerberus-source code snippet using org.cerberus.service.appium.impl.AppiumService.getCoordinates

Source:AppiumService.java Github

copy

Full Screen

...113 public MessageEvent click(final Session session, final Identifier identifier) {114 try {115 final TouchAction action = new TouchAction(session.getAppiumDriver());116 if (identifier.isSameIdentifier(Identifier.Identifiers.COORDINATE)) {117 final Coordinates coordinates = getCoordinates(identifier);118 action.tap(coordinates.getX(), coordinates.getY()).perform();119 } else {120 action.tap(getElement(session, identifier, false, false)).perform();121 }122 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_CLICK).resolveDescription("ELEMENT", identifier.toString());123 } catch (NoSuchElementException e) {124 if (LOG.isDebugEnabled()) {125 LOG.debug(e.getMessage());126 }127 return new MessageEvent(MessageEventEnum.ACTION_FAILED_CLICK_NO_SUCH_ELEMENT).resolveDescription("ELEMENT", identifier.toString());128 } catch (WebDriverException e) {129 LOG.warn(e.getMessage());130 return parseWebDriverException(e);131 }132 }133 /**134 * @author vertigo17135 * @param exception the exception need to be parsed by Cerberus136 * @return A new Event Message with selenium related description137 */138 private MessageEvent parseWebDriverException(WebDriverException exception) {139 MessageEvent mes;140 LOG.fatal(exception.toString());141 mes = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELENIUM_CONNECTIVITY);142 mes.setDescription(mes.getDescription().replace("%ERROR%", exception.getMessage().split("\n")[0]));143 return mes;144 }145 /**146 * Get the {@link Coordinates} represented by the given {@link Identifier}147 *148 * @param identifier the {@link Identifier} to parse to get the149 * {@link Coordinates}150 * @return the {@link Coordinates} represented by the given151 * {@link Identifier}152 * @throws NoSuchElementException if no {@link Coordinates} can be found153 * inside the given {@link Identifier}154 */155 private Coordinates getCoordinates(final Identifier identifier) {156 if (identifier == null || !identifier.isSameIdentifier(Identifier.Identifiers.COORDINATE)) {157 throw new NoSuchElementException("Unable to get coordinates from a non coordinates identifier");158 }159 final Matcher coordinates = Identifier.Identifiers.COORDINATE_VALUE_PATTERN.matcher(identifier.getLocator());160 if (!coordinates.find()) {161 throw new NoSuchElementException("Bad coordinates format");162 }163 try {164 return new Coordinates(165 Integer.valueOf(coordinates.group("xCoordinate")),166 Integer.valueOf(coordinates.group("yCoordinate"))167 );168 } catch (NumberFormatException e) {169 throw new NoSuchElementException("Bad coordinates format", e);...

Full Screen

Full Screen

getCoordinates

Using AI Code Generation

copy

Full Screen

1Coordinates coordinates = appiumService.getCoordinates(element);2Point center = coordinates.getCenter();3int x = center.getX();4int y = center.getY();5Point center = coordinates.getCenter();6int x = center.getX();7int y = center.getY();8Point center = coordinates.getCenter();9int x = center.getX();10int y = center.getY();11Point center = coordinates.getCenter();12int x = center.getX();

Full Screen

Full Screen

getCoordinates

Using AI Code Generation

copy

Full Screen

1WebElement element = driver.findElement(By.id("elementId"));2AppiumService appiumService = new AppiumService();3int[] coordinates = appiumService.getCoordinates(element, driver);4int x = coordinates[0];5int y = coordinates[1];6WebElement element = driver.findElement(By.id("elementId"));7AppiumService appiumService = new AppiumService();8int[] center = appiumService.getElementCenter(element, driver);9int centerX = center[0];10int centerY = center[1];

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful