use of com.testsigma.automator.actions.ElementSearchCriteria in project testsigma by testsigmahq.
the class DriverSessionActionsController method searchByIndexAndSendKeys.
@PostMapping(value = "/search_and_send_keys")
@ResponseStatus(HttpStatus.ACCEPTED)
public void searchByIndexAndSendKeys(@PathVariable("session_id") String sessionId, @RequestParam("platform") Platform platform, @RequestParam("locatorType") LocatorType locatorType, @RequestParam("byValue") String byValue, @RequestParam("index") Integer index, @RequestParam("keys") String keys, @Nullable @RequestParam(value = "webViewName", required = false) String webViewName) throws Exception {
FindByType findByType = FindByType.getType(locatorType);
ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(findByType, byValue);
log.info("Request for searching the Element By Index and Tapping on it, in session - " + sessionId + ",for locatorType - " + locatorType + ", byValue - " + byValue + ", index - " + index + ", keys -" + keys);
driverSessionCommand.findElementByIndexAndSendKey(sessionId, platform, elementSearchCriteria, index, keys, webViewName);
}
use of com.testsigma.automator.actions.ElementSearchCriteria in project testsigma by testsigmahq.
the class DriverSessionActionsController method searchByIndexAndTapElement.
@PostMapping(value = "/search_and_tap")
@ResponseStatus(HttpStatus.ACCEPTED)
public void searchByIndexAndTapElement(@PathVariable("session_id") String sessionId, @RequestParam("platform") Platform platform, @RequestParam("locatorType") LocatorType locatorType, @RequestParam("byValue") String byValue, @RequestParam("index") Integer index, @Nullable @RequestParam(value = "webViewName", required = false) String webViewName) throws Exception {
FindByType findByType = FindByType.getType(locatorType);
ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(findByType, byValue);
log.info("Request for searching the Element By Index and Tapping on it, in session - " + sessionId + ",for locatorType - " + locatorType + ", byValue - " + byValue + ", index - " + index);
driverSessionCommand.findElementByIndexAndTap(sessionId, platform, elementSearchCriteria, index, webViewName);
}
use of com.testsigma.automator.actions.ElementSearchCriteria in project testsigma by testsigmahq.
the class GetUniqueXpathAction method execute.
@Override
protected void execute() throws Exception {
AppiumDriver driver = getDriver();
List<RemoteWebElement> webElements = new ArrayList<>();
ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(FindByType.XPATH, webElement.getXpath());
if (webElement.getWebViewName() != null) {
driver.context(webElement.getWebViewName());
webElements = driver.findElements(elementSearchCriteria.getBy());
driver.context("NATIVE_APP");
} else {
webElements = driver.findElements(elementSearchCriteria.getBy());
}
if (webElements.size() > 1) {
String absoluteXpath = this.optimizeXpathUsingAttributes(webElement);
elementSearchCriteria.setByValue(absoluteXpath);
if (driver.findElements(elementSearchCriteria.getBy()).size() != 1) {
String relativeXpath = this.optimizeXpathRelatively(webElement);
elementSearchCriteria.setByValue(relativeXpath);
if (driver.findElements(elementSearchCriteria.getBy()).size() != 1) {
setActualValue(null);
} else
setActualValue(relativeXpath);
} else {
setActualValue(absoluteXpath);
}
} else {
setActualValue(null);
}
}
use of com.testsigma.automator.actions.ElementSearchCriteria in project testsigma by testsigmahq.
the class CheckElementIsInDifferentFrame method execute.
@Override
protected void execute() throws Exception {
ElementPropertiesEntity elementPropertiesEntity = getElementPropertiesEntity(NaturalTextActionConstants.TESTS_TEP_DATA_MAP_KEY_ELEMENT);
if (StringUtils.isBlank(elementPropertiesEntity.getLocatorValue())) {
throw new Exception();
}
ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(elementPropertiesEntity.getFindByType(), elementPropertiesEntity.getLocatorValue());
WebElement elementInIframe = null;
JavascriptExecutor jsExecutor = driver;
String defaultPathName = (String) jsExecutor.executeScript("return window.location.pathname");
List<WebElement> iframes = getDriver().findElements(By.xpath("//iframe|//frame"));
Integer i = 1;
for (WebElement iframe : iframes) {
try {
getDriver().switchTo().defaultContent();
getDriver().switchTo().frame(iframe);
elementInIframe = getDriver().findElement(elementSearchCriteria.getBy());
Map<String, String> suggestions = new HashMap<String, String>();
// iframe.getAttribute("name")
suggestions.put("Frame Name", "");
suggestions.put("Frame Index", new Integer(i).toString());
engineResult.getMetaData().setSuggestions(new JSONObject().put("list", suggestions));
this.suggestionActionResult = SuggestionActionResult.Success;
break;
} catch (Exception e) {
continue;
}
}
if (defaultPathName != jsExecutor.executeScript("return window.location.pathname")) {
getDriver().switchTo().defaultContent();
List<WebElement> elements = getDriver().findElementsByXPath("//iframe[@src=\"" + defaultPathName + "\"]");
if (elements.size() > 0) {
getDriver().switchTo().frame(elements.get(0));
}
}
if (elementInIframe == null)
throw exception;
}
use of com.testsigma.automator.actions.ElementSearchCriteria in project testsigma by testsigmahq.
the class DriverSessionActionsController method searchByIndexAndClearElement.
@PostMapping(value = "/search_and_clear")
@ResponseStatus(HttpStatus.ACCEPTED)
public void searchByIndexAndClearElement(@PathVariable("session_id") String sessionId, @RequestParam("platform") Platform platform, @RequestParam("locatorType") LocatorType locatorType, @RequestParam("byValue") String byValue, @RequestParam("index") Integer index, @Nullable @RequestParam(value = "webViewName", required = false) String webViewName) throws Exception {
FindByType findByType = FindByType.getType(locatorType);
ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(findByType, byValue);
log.info("Request for searching the Element By Index and Clearing it, in session - " + sessionId + ",for locatorType - " + locatorType + ", byValue - " + byValue + ", index - " + index);
driverSessionCommand.findElementByIndexAndClear(sessionId, platform, elementSearchCriteria, index, webViewName);
}
Aggregations