Best Testsigma code snippet using com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException.MobileAutomationServerCommandExecutionException
Source:DriverSessionActionsController.java
...8 */9package com.testsigma.agent.controllers;10import com.testsigma.agent.dto.MobileElementDTO;11import com.testsigma.agent.dto.ScreenDimensions;12import com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException;13import com.testsigma.agent.mappers.MobileElementMapper;14import com.testsigma.agent.mobile.DriverSessionCommand;15import com.testsigma.agent.request.SendKeysRequest;16import com.testsigma.agent.request.TapPoint;17import com.testsigma.automator.entity.LocatorType;18import com.testsigma.automator.entity.Platform;19import com.testsigma.automator.actions.ElementSearchCriteria;20import com.testsigma.automator.actions.FindByType;21import com.testsigma.automator.actions.mobile.MobileElement;22import lombok.RequiredArgsConstructor;23import lombok.extern.log4j.Log4j2;24import org.openqa.selenium.ScreenOrientation;25import org.springframework.beans.factory.annotation.Autowired;26import org.springframework.http.HttpStatus;27import org.springframework.http.MediaType;28import org.springframework.web.bind.annotation.*;29import javax.annotation.Nullable;30import java.util.List;31@Log4j232@RestController33@RequestMapping(path = "/api/v1/session_actions/{session_id}")34@RequiredArgsConstructor(onConstructor = @__(@Autowired))35public class DriverSessionActionsController {36 private final DriverSessionCommand driverSessionCommand;37 private final MobileElementMapper mobileElementMapper;38 /**39 * Tap on the current page at X,Y point40 *41 * @param sessionId42 * @param tapPoint43 * @throws MobileAutomationServerCommandExecutionException44 */45 @PostMapping(value = "/tap")46 @ResponseStatus(HttpStatus.ACCEPTED)47 public void tap(@PathVariable("session_id") String sessionId,48 @RequestBody TapPoint tapPoint)49 throws MobileAutomationServerCommandExecutionException {50 log.info("Request for tap received in session - " + sessionId + " at point - " + tapPoint);51 driverSessionCommand.tap(sessionId, tapPoint);52 }53 /**54 * swipe on the current page from point1 to point255 *56 * @param sessionId57 * @param tapPoints58 * @throws MobileAutomationServerCommandExecutionException59 */60 @PostMapping(value = "/swipe")61 @ResponseStatus(HttpStatus.ACCEPTED)62 public void swipe(@PathVariable("session_id") String sessionId,63 @RequestBody List<TapPoint> tapPoints)64 throws MobileAutomationServerCommandExecutionException {65 log.info("Request for tap received in session - " + sessionId + " at point - " + tapPoints);66 driverSessionCommand.swipe(sessionId, tapPoints);67 }68 /**69 * Taps on the given mobile element in given remote web driver session.70 *71 * @param sessionId72 * @param mobileElement73 * @return no application specific return value. Only corresponding http status codes.74 * @throws MobileAutomationServerCommandExecutionException75 */76 @PostMapping(value = "/tap_element")77 @ResponseStatus(HttpStatus.ACCEPTED)78 public void tapElement(@PathVariable("session_id") String sessionId,79 @RequestBody MobileElement mobileElement)80 throws MobileAutomationServerCommandExecutionException {81 log.info("Request for tap received in session - " + sessionId + " for element - " + mobileElement);82 driverSessionCommand.tapOnElement(sessionId, mobileElement);83 }84 /**85 * If this element is a text entry element, this will clear the value. Has no effect on other86 * elements. Text entry elements are INPUT and TEXTAREA elements.87 *88 * @param sessionId89 * @param mobileElement90 * @return no application specific return value. Only corresponding http status codes.91 * @throws MobileAutomationServerCommandExecutionException92 */93 @PostMapping(value = "/clear_element")94 @ResponseStatus(HttpStatus.ACCEPTED)95 public void clearElement(@PathVariable("session_id") String sessionId,96 @RequestBody MobileElement mobileElement)97 throws MobileAutomationServerCommandExecutionException {98 log.info("Request for clear element received in session - " + sessionId + " for element - " + mobileElement);99 driverSessionCommand.clearElement(sessionId, mobileElement);100 }101 /**102 * Send keys to the given mobile element in given remote web driver session.103 *104 * @param sessionId105 * @param sendKeysRequest106 * @return no application specific return value. Only corresponding http status codes.107 * @throws MobileAutomationServerCommandExecutionException108 */109 @PostMapping(value = "/send_keys")110 @ResponseStatus(HttpStatus.ACCEPTED)111 public void sendKeys(@PathVariable("session_id") String sessionId,112 @RequestBody SendKeysRequest sendKeysRequest)113 throws MobileAutomationServerCommandExecutionException {114 log.info("Request for send keys received in session - " + sessionId + " with keys - " + sendKeysRequest);115 driverSessionCommand.sendKeys(sessionId, sendKeysRequest.getMobileElement(), sendKeysRequest.getKeys());116 }117 /**118 * Takes a screenshot of the current page in the given session and returns the content119 *120 * @param sessionId121 * @return base64 encoded formatted image content as string value122 * @throws MobileAutomationServerCommandExecutionException123 */124 @GetMapping(value = "/screenshot", produces = MediaType.TEXT_PLAIN_VALUE)125 public String getScreenshot(@PathVariable("session_id") String sessionId) throws MobileAutomationServerCommandExecutionException {126 log.info("Request for screenshot in session - " + sessionId);127 return driverSessionCommand.pageScreenshot(sessionId);128 }129 /**130 * Gets the page source of the current page131 *132 * @param sessionId133 * @return MobileElementDTO - A tree structure of page element134 * @throws MobileAutomationServerCommandExecutionException135 */136 @GetMapping(value = "/page_source", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)137 public MobileElementDTO getPageSource(@PathVariable("session_id") String sessionId, @RequestParam("platform") Platform platform)138 throws MobileAutomationServerCommandExecutionException {139 log.info("Request for page source in session - " + sessionId + " Platform - " + platform);140 MobileElement mobileElement = driverSessionCommand.pageSourceElements(sessionId, platform);141 MobileElementDTO mobileElementDTO = mobileElementMapper.map(mobileElement);142 return mobileElementDTO;143 }144 /**145 * navigate to the previous page from the current page in the current session146 *147 * @param sessionId148 * @return no application specific return value. Only corresponding http status codes.149 * @throws MobileAutomationServerCommandExecutionException150 */151 @GetMapping(value = "/navigate/back")152 @ResponseStatus(HttpStatus.OK)153 public void navigateBack(@PathVariable("session_id") String sessionId)154 throws MobileAutomationServerCommandExecutionException {155 log.info("Request for navigate back in session - " + sessionId);156 driverSessionCommand.back(sessionId);157 }158 /**159 * Fetch the width and height of the current screen to which a session is in progress.160 *161 * @param sessionId162 * @return ScreenDimensions object which has screen height and width163 * @throws MobileAutomationServerCommandExecutionException164 */165 @GetMapping(value = "/screen_dimensions")166 @ResponseStatus(HttpStatus.OK)167 public ScreenDimensions screenDimensions(@PathVariable("session_id") String sessionId)168 throws MobileAutomationServerCommandExecutionException {169 log.info("Request for screen dimensions in session - " + sessionId);170 return driverSessionCommand.getScreenDimensions(sessionId);171 }172 @GetMapping(value = "/find_elements")173 @ResponseStatus(HttpStatus.OK)174 public List<MobileElementDTO> findElements(@PathVariable("session_id") String sessionId,175 @RequestParam("platform") Platform platform,176 @RequestParam("locatorType") LocatorType locatorType,177 @RequestParam("byValue") String byValue)178 throws MobileAutomationServerCommandExecutionException {179 FindByType findByType = FindByType.getType(locatorType);180 ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(findByType, byValue);181 log.info("Request for searching Elements in session - " + sessionId);182 List<MobileElement> mobileElements = driverSessionCommand.findElements(sessionId, platform, elementSearchCriteria);183 return mobileElementMapper.map(mobileElements);184 }185 @GetMapping(value = "navigate/home")186 @ResponseStatus(HttpStatus.OK)187 public void goToHome(@PathVariable("session_id") String sessionId) throws Exception {188 driverSessionCommand.goToHome(sessionId);189 }190 @GetMapping(value = "/change_orientation")191 @ResponseStatus(HttpStatus.OK)192 public void changeOrientation(@PathVariable("session_id") String sessionId) throws Exception {193 driverSessionCommand.changeOrientation(sessionId);194 }195 @GetMapping(value = "/get_orientation")196 @ResponseStatus(HttpStatus.OK)197 public ScreenOrientation getOrientation(@PathVariable("session_id") String sessionId) throws Exception {198 return driverSessionCommand.getOrientation(sessionId);199 }200 @PostMapping(value = "/search_and_send_keys")201 @ResponseStatus(HttpStatus.ACCEPTED)202 public void searchByIndexAndSendKeys(@PathVariable("session_id") String sessionId,203 @RequestParam("platform") Platform platform,204 @RequestParam("locatorType") LocatorType locatorType,205 @RequestParam("byValue") String byValue,206 @RequestParam("index") Integer index,207 @RequestParam("keys") String keys,208 @Nullable @RequestParam(value = "webViewName", required = false) String webViewName)209 throws Exception {210 FindByType findByType = FindByType.getType(locatorType);211 ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(findByType, byValue);212 log.info("Request for searching the Element By Index and Tapping on it, in session - " + sessionId +213 ",for locatorType - " + locatorType + ", byValue - " + byValue + ", index - " + index + ", keys -" + keys);214 driverSessionCommand.findElementByIndexAndSendKey(sessionId, platform, elementSearchCriteria, index, keys, webViewName);215 }216 @PostMapping(value = "/search_and_tap")217 @ResponseStatus(HttpStatus.ACCEPTED)218 public void searchByIndexAndTapElement(@PathVariable("session_id") String sessionId,219 @RequestParam("platform") Platform platform,220 @RequestParam("locatorType") LocatorType locatorType,221 @RequestParam("byValue") String byValue,222 @RequestParam("index") Integer index,223 @Nullable @RequestParam(value = "webViewName", required = false) String webViewName)224 throws Exception {225 FindByType findByType = FindByType.getType(locatorType);226 ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(findByType, byValue);227 log.info("Request for searching the Element By Index and Tapping on it, in session - " + sessionId +228 ",for locatorType - " + locatorType + ", byValue - " + byValue + ", index - " + index);229 driverSessionCommand.findElementByIndexAndTap(sessionId, platform, elementSearchCriteria, index, webViewName);230 }231 @PostMapping(value = "/search_and_clear")232 @ResponseStatus(HttpStatus.ACCEPTED)233 public void searchByIndexAndClearElement(@PathVariable("session_id") String sessionId,234 @RequestParam("platform") Platform platform,235 @RequestParam("locatorType") LocatorType locatorType,236 @RequestParam("byValue") String byValue,237 @RequestParam("index") Integer index,238 @Nullable @RequestParam(value = "webViewName", required = false) String webViewName)239 throws Exception {240 FindByType findByType = FindByType.getType(locatorType);241 ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(findByType, byValue);242 log.info("Request for searching the Element By Index and Clearing it, in session - " + sessionId +243 ",for locatorType - " + locatorType + ", byValue - " + byValue + ", index - " + index);244 driverSessionCommand.findElementByIndexAndClear(sessionId, platform, elementSearchCriteria, index, webViewName);245 }246 @PostMapping(value = "/unique_xpath")247 @ResponseStatus(HttpStatus.OK)248 public String GetUniqueXpath(@PathVariable("session_id") String sessionId,249 @RequestParam("platform") Platform platform,250 @RequestBody MobileElement mobileElement)251 throws MobileAutomationServerCommandExecutionException {252 log.info("Request for Getting Unique Xpath of the Element, in session - " + sessionId);253 return driverSessionCommand.getUniqueXpath( sessionId, platform , mobileElement) ;254 }255}...
Source:AgentDeviceActionsController.java
...6 * ****************************************************************************7 *8 */9package com.testsigma.agent.controllers;10import com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException;11import com.testsigma.agent.mobile.DeviceCommand;12import com.testsigma.agent.request.TapPoint;13import lombok.RequiredArgsConstructor;14import lombok.extern.log4j.Log4j2;15import org.springframework.beans.factory.annotation.Autowired;16import org.springframework.http.HttpStatus;17import org.springframework.web.bind.annotation.*;18@Log4j219@RestController20@RequestMapping(path = "/api/v1/device_actions/{unique_id}")21@RequiredArgsConstructor(onConstructor = @__(@Autowired))22public class AgentDeviceActionsController {23 private final DeviceCommand deviceCommand;24 /**25 * Tap on the current page at the given X, Y point26 *27 * @param uniqueId28 * @param tapPoint29 * @return no application specific return value. Only corresponding http status codes.30 * @throws MobileAutomationServerCommandExecutionException31 */32 @PostMapping(value = "/tap")33 @ResponseStatus(HttpStatus.ACCEPTED)34 public void tap(@PathVariable("unique_id") String uniqueId, @RequestBody TapPoint tapPoint)35 throws MobileAutomationServerCommandExecutionException {36 log.info("Received a request for a Tap on device - " + uniqueId + " at (" + tapPoint.getX() +37 "," + tapPoint.getY() + ")");38 deviceCommand.tap(uniqueId, tapPoint);39 }40 /**41 * swipe on the current page from point X1, Y1 to point X2, Y242 *43 * @param uniqueId44 * @param tapPoints45 * @return no application specific return value. Only corresponding http status codes.46 * @throws MobileAutomationServerCommandExecutionException47 */48 @PostMapping(value = "/swipe")49 @ResponseStatus(HttpStatus.ACCEPTED)50 public void swipe(@PathVariable("unique_id") String uniqueId, @RequestBody TapPoint[] tapPoints)51 throws MobileAutomationServerCommandExecutionException {52 TapPoint fromTapPoint = tapPoints[0];53 TapPoint toTapPoint = tapPoints[1];54 log.info(55 "Received a request for a swipe operation on device " + uniqueId + " from (" + fromTapPoint56 .getX() +57 "," + fromTapPoint.getY() + ") to (" + toTapPoint.getX() + "," + toTapPoint.getY() + ")");58 deviceCommand.swipe(uniqueId, tapPoints);59 }60 /**61 * navigate to the previous page from the current page in the device62 *63 * @param uniqueId64 * @return no application specific return value. Only corresponding http status codes.65 * @throws MobileAutomationServerCommandExecutionException66 */67 @GetMapping(value = "/navigate/back")68 @ResponseStatus(HttpStatus.OK)69 public void navigateBack(@PathVariable("unique_id") String uniqueId)70 throws MobileAutomationServerCommandExecutionException {71 log.info("Navigating to back for device - " + uniqueId);72 deviceCommand.back(uniqueId);73 }74}...
Source:DeviceCommand.java
...4 * All rights reserved.5 * ****************************************************************************6 */7package com.testsigma.agent.mobile;8import com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException;9import com.testsigma.agent.mobile.android.CommandExecutor;10import com.testsigma.agent.request.TapPoint;11import lombok.RequiredArgsConstructor;12import lombok.extern.log4j.Log4j2;13import org.springframework.beans.factory.annotation.Autowired;14import org.springframework.stereotype.Component;15@Log4j216@RequiredArgsConstructor(onConstructor = @__(@Autowired))17@Component18public class DeviceCommand {19 private final DeviceContainer deviceContainer;20 private final CommandExecutor commandExecutor;21 public void tap(String uniqueId, TapPoint tapPoint)22 throws MobileAutomationServerCommandExecutionException {23 try {24 MobileDevice mobileDevice = deviceContainer.getDevice(uniqueId);25 commandExecutor.executeCommand(mobileDevice.iDevice, "input tap " + tapPoint.getX() + " " + tapPoint.getY());26 } catch (Exception e) {27 log.error(e.getMessage(), e);28 throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);29 }30 }31 public void swipe(String uniqueId, TapPoint[] tapPoints)32 throws MobileAutomationServerCommandExecutionException {33 try {34 MobileDevice mobileDevice = deviceContainer.getDevice(uniqueId);35 commandExecutor.executeCommand(mobileDevice.iDevice,36 "input swipe " + tapPoints[0].getX() + " " + tapPoints[0].getY() + " " + tapPoints[1].getX() + " " + tapPoints[1]37 .getY());38 } catch (Exception e) {39 log.error(e.getMessage(), e);40 throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);41 }42 }43 public void back(String uniqueId) throws MobileAutomationServerCommandExecutionException {44 try {45 MobileDevice mobileDevice = deviceContainer.getDevice(uniqueId);46 commandExecutor.executeCommand(mobileDevice.iDevice, "input keyevent KEYCODE_BACK");47 } catch (Exception e) {48 log.error(e.getMessage(), e);49 throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);50 }51 }52}...
MobileAutomationServerCommandExecutionException
Using AI Code Generation
1package com.testsigma.agent.exception;2public class MobileAutomationServerCommandExecutionException extends MobileAutomationServerException {3 private static final long serialVersionUID = 1L;4 public MobileAutomationServerCommandExecutionException(String message) {5 super(message);6 }7 public MobileAutomationServerCommandExecutionException(Throwable cause) {8 super(cause);9 }10 public MobileAutomationServerCommandExecutionException(String message, Throwable cause) {11 super(message, cause);12 }13}14package com.testsigma.agent.exception;15public class MobileAutomationServerException extends Exception {16 private static final long serialVersionUID = 1L;17 public MobileAutomationServerException(String message) {18 super(message);19 }20 public MobileAutomationServerException(Throwable cause) {21 super(cause);22 }23 public MobileAutomationServerException(String message, Throwable cause) {24 super(message, cause);25 }26}27package com.testsigma.agent.exception;28public class MobileAutomationServerExecutionException extends MobileAutomationServerException {29 private static final long serialVersionUID = 1L;30 public MobileAutomationServerExecutionException(String message) {31 super(message);32 }33 public MobileAutomationServerExecutionException(Throwable cause) {34 super(cause);35 }36 public MobileAutomationServerExecutionException(String message, Throwable cause) {37 super(message, cause);38 }39}40package com.testsigma.agent.exception;41public class MobileAutomationServerException extends Exception {42 private static final long serialVersionUID = 1L;43 public MobileAutomationServerException(String message) {44 super(message);45 }46 public MobileAutomationServerException(Throwable cause) {47 super(cause);48 }49 public MobileAutomationServerException(String message, Throwable cause) {50 super(message, cause);51 }52}53package com.testsigma.agent.exception;54public class MobileAutomationServerExecutionException extends MobileAutomationServerException {55 private static final long serialVersionUID = 1L;
MobileAutomationServerCommandExecutionException
Using AI Code Generation
1package com.testsigma.agent.exception;2public class MobileAutomationServerCommandExecutionException extends Exception {3public MobileAutomationServerCommandExecutionException(String message) {4super(message);5}6}7package com.testsigma.agent.exception;8public class MobileAutomationServerCommandExecutionException extends Exception {9public MobileAutomationServerCommandExecutionException(String message, Throwable cause) {10super(message, cause);11}12}13package com.testsigma.agent.exception;14public class MobileAutomationServerCommandExecutionException extends Exception {15public MobileAutomationServerCommandExecutionException(Throwable cause) {16super(cause);17}18}19package com.testsigma.agent.exception;20public class MobileAutomationServerCommandExecutionException extends Exception {21public MobileAutomationServerCommandExecutionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {22super(message, cause, enableSuppression, writableStackTrace);23}24}25package com.testsigma.agent.exception;26public class MobileAutomationServerCommandExecutionException extends Exception {27public MobileAutomationServerCommandExecutionException() {28super();29}30}31package com.testsigma.agent.exception;32public class MobileAutomationServerCommandExecutionException extends Exception {33public MobileAutomationServerCommandExecutionException(String message) {34super(message);35}36}37package com.testsigma.agent.exception;38public class MobileAutomationServerCommandExecutionException extends Exception {39public MobileAutomationServerCommandExecutionException(String message, Throwable cause) {40super(message, cause);41}42}43package com.testsigma.agent.exception;
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!