本文整理汇总了Java中com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion类的典型用法代码示例。如果您正苦于以下问题:Java WebElementSelectionCriterion类的具体用法?Java WebElementSelectionCriterion怎么用?Java WebElementSelectionCriterion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebElementSelectionCriterion类属于com.musala.atmosphere.commons.webelement.selection包,在下文中一共展示了WebElementSelectionCriterion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTapWebElementInList
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testTapWebElementInList() {
String[] expectedResult = {"submit", "cancel", "getSizeTest", "create"};
List<UiWebElement> webElements = webView.findElements(WebElementSelectionCriterion.TAG,
EXISTING_WEB_ELEMENT_TAG);
assertEquals("Number of expected web elements found does not match the actual one.",
expectedResult.length,
webElements.size());
int index = 0;
for (UiWebElement webElement : webElements) {
assertEquals(ATTRIBUTE_VALUE_MISSMATCH_ERROR_MESSAGE,
expectedResult[index],
webElement.getAttribute("name"));
index++;
}
UiWebElement closeButton = webElements.get(1);
closeButton.tap();
String dynamicAtributeValue = (String) closeButton.getAttribute(DYNAMIC_ATTRIBUTE_NAME);
assertEquals(TAP_FAILED_MESSAGE, CANCEL_BUTTON_DYNAMIC_ATTRIBUTE_VALUE, dynamicAtributeValue);
assertEquals(ATTRIBUTE_VALUE_MISSMATCH_ERROR_MESSAGE, expectedResult[1], closeButton.getAttribute("name"));
}
示例2: findElements
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
/**
* Finds {@link UiWebElement UiWebElements} within the current {@link WebElement} by the given
* {@link WebElementSelectionCriterion selection criterion} and the corresponding value.
*
* @param selectionCriterion
* - a {@link WebElementSelectionCriterion selection criterion}
* @param criterionValue
* - a {@link WebElementSelectionCriterion selection criterion value}
* @return the wanted element
* @throws InvalidCssQueryException
* if {@link WebElementSelectionCriterion selection criterion} is set to CSS_SELECTOR and the query is
* invalid
*/
@SuppressWarnings("unchecked")
public List<UiWebElement> findElements(WebElementSelectionCriterion selectionCriterion, String criterionValue) {
List<UiWebElement> webElements = new ArrayList<>();
String xpathCriterionValue = WebElementSelectionCriterionConverter.convertToXpathQuery(selectionCriterion,
criterionValue);
String findElementQuery = this.xpathQuery + xpathCriterionValue;
List<Map<String, Object>> attributesList = (List<Map<String, Object>>) deviceCommunicator.sendAction(RoutingAction.FIND_WEB_ELEMENTS,
findElementQuery);
int index = 1;
for (Map<String, Object> elementAttributes : attributesList) {
String elementXpathCriterionValue = WebElementSelectionCriterionConverter.convertToXpathQuery(selectionCriterion,
criterionValue,
index);
String findSingleElementQuery = this.xpathQuery + elementXpathCriterionValue;
UiWebElement webElement = new UiWebElement(deviceCommunicator,
elementAttributes,
findSingleElementQuery);
webElements.add(webElement);
index++;
}
return webElements;
}
示例3: convertToXpathQuery
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
/**
* Converts the given {@link WebElementSelectionCriterion selection criterion} to xpath query.
*
* @param selectionCriterion
* - type of the selection criterion
* @param criterionValue
* - value that is used for matching
* @return the converted xpath query
* @throws InvalidCssQueryException
* if {@link WebElementSelectionCriterion selection criterion} is set to CSS_SELECTOR and the query is
* invalid
*/
public static String convertToXpathQuery(WebElementSelectionCriterion selectionCriterion, String criterionValue) {
switch (selectionCriterion) {
case TAG:
return String.format(TAG_PATTERN, criterionValue);
case ID:
case NAME:
case CLASS:
case LINK:
return String.format(ATTRIBUTE_PATTERN, selectionCriterion.getName(), criterionValue);
case PARTIAL_LINK:
return String.format(PARTIAL_LINK_PATTERN, selectionCriterion.getName(), criterionValue);
case CSS_SELECTOR:
return CssToXPathConverter.convertCssToXPath(criterionValue);
case XPATH:
return criterionValue;
default:
return null;
}
}
示例4: testFindElementWhenPresentByAttribute
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testFindElementWhenPresentByAttribute() {
String expectedAttributeValue = "header";
UiWebElement webElement = webView.findElement(WebElementSelectionCriterion.ID, EXISTING_WEB_ELEMENT_ID);
assertEquals(ATTRIBUTE_MISSMATCH_ERROR_MESSAGE, expectedAttributeValue, webElement.getAttribute("class"));
expectedAttributeValue = "btn";
webElement = webView.findElement(WebElementSelectionCriterion.NAME, EXISTING_BUTTON_NAME);
assertEquals(ATTRIBUTE_MISSMATCH_ERROR_MESSAGE, expectedAttributeValue, webElement.getAttribute("id"));
}
示例5: testFindMultipleElementsByAttribute
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testFindMultipleElementsByAttribute() {
int expectedCount = 9;
List<UiWebElement> elements = webView.findElements(WebElementSelectionCriterion.TAG, EXISTING_WEB_ELEMENT_TAG);
assertEquals(ATTRIBUTE_MISSMATCH_ERROR_MESSAGE, expectedCount, elements.size());
expectedCount = 2;
elements = webView.findElements(WebElementSelectionCriterion.NAME, EXISTING_WEB_ELEMENT_NAME);
assertEquals(ATTRIBUTE_MISSMATCH_ERROR_MESSAGE, expectedCount, elements.size());
}
示例6: testFindMultipleElementsByXpath
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testFindMultipleElementsByXpath() {
int expectedCount = 5;
List<UiWebElement> elements = webView.findElements(WebElementSelectionCriterion.XPATH,
EXISTING_ELEMENTS_XPATH_QUERY);
assertEquals(ATTRIBUTE_MISSMATCH_ERROR_MESSAGE, expectedCount, elements.size());
}
示例7: testFindElementWhenMatchingElementsExistOnDifferentLevels
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testFindElementWhenMatchingElementsExistOnDifferentLevels() {
String expectedName = "home";
UiWebElement firstMatch = webView.findElement(WebElementSelectionCriterion.CLASS, LINK_CLASS);
assertEquals(TEXT_MISSMATCH_ERROR_MESSAGE, expectedName, firstMatch.getAttribute("name"));
}
示例8: testFindElementInWebElementWhenNotDirectChild
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testFindElementInWebElementWhenNotDirectChild() {
String expectedName = "contacts";
UiWebElement parentElement = webView.findElement(WebElementSelectionCriterion.ID, FOOTER_ID);
UiWebElement descendant = parentElement.findElement(WebElementSelectionCriterion.ID, CONTACTS_ID);
assertEquals(TEXT_MISSMATCH_ERROR_MESSAGE, expectedName, descendant.getAttribute("name"));
}
示例9: testFindElementInWebElementWhenDirectChild
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testFindElementInWebElementWhenDirectChild() {
String expectedAttributeValue = "ul-info";
UiWebElement parentElement = webView.findElement(WebElementSelectionCriterion.ID, FOOTER_ID);
UiWebElement child = parentElement.findElement(WebElementSelectionCriterion.TAG, LINKS_PARENT_ID);
assertEquals(ATTRIBUTE_MISSMATCH_ERROR_MESSAGE, expectedAttributeValue, child.getAttribute("class"));
}
示例10: testWaitForExistingElement
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testWaitForExistingElement() {
UiWebElement createElementButton = webView.findElement(WebElementSelectionCriterion.ID,
CREATE_ELEMENT_BUTTON_ID);
createElementButton.tap();
assertTrue("The method returned false, but the element existed on the screen.",
webView.waitForElementExists(WebElementSelectionCriterion.ID,
TEST_ELEMENT_ID,
WAIT_FOR_CONDITION_TIMEOUT));
}
示例11: testWaitForUnexistingElement
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testWaitForUnexistingElement() {
assertFalse("The method returned true, but the element didn't exist on the screen.",
webView.waitForElementExists(WebElementSelectionCriterion.ID,
TEST_ELEMENT_ID,
WAIT_FOR_CONDITION_TIMEOUT));
}
示例12: testTapWebElement
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testTapWebElement() {
UiWebElement webElement = webView.findElement(WebElementSelectionCriterion.ID, WEB_ELEMENT_ID);
webElement.tap();
String dynamicAtributeValue = (String) webElement.getAttribute(DYNAMIC_ATTRIBUTE_NAME);
assertEquals(TAP_FAILED_MESSAGE, SUBMIT_BUTTON_DYNAMIC_ATTRIBUTE_VALUE, dynamicAtributeValue);
}
示例13: testIsWebElementDisplayedPropertyDisplay
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testIsWebElementDisplayedPropertyDisplay() {
UiWebElement webElement = webView.findElement(WebElementSelectionCriterion.ID, DISPLAY_ELEMENT_ID);
String expectedValue = "none";
String expectedProperty = "display";
assertEquals(EXPECTED_CSS_PROPERTY_FAIL_MESSAGE, expectedValue, webElement.getCssValue(expectedProperty));
assertFalse(HIDDEN_ELEMENT_IS_DISPLAYED_FAIL_MESSAGE, webElement.isDisplayed());
}
示例14: testIsWebElementDisplayedPropertyVisibility
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testIsWebElementDisplayedPropertyVisibility() {
UiWebElement webElement = webView.findElement(WebElementSelectionCriterion.ID, VISIBIL_ELEMENT_ID);
String expectedValue = "hidden";
String expectedProperty = "visibility";
assertEquals(EXPECTED_CSS_PROPERTY_FAIL_MESSAGE, expectedValue, webElement.getCssValue(expectedProperty));
assertFalse(HIDDEN_ELEMENT_IS_DISPLAYED_FAIL_MESSAGE, webElement.isDisplayed());
}
示例15: testIsWebElementWithZeroOpacityDisplayed
import com.musala.atmosphere.commons.webelement.selection.WebElementSelectionCriterion; //导入依赖的package包/类
@Test
public void testIsWebElementWithZeroOpacityDisplayed() {
UiWebElement webElement = webView.findElement(WebElementSelectionCriterion.CLASS, ZERO_OPACITY_ELEMENT_CLASS);
String expectedValue = "0";
String expectedProperty = "opacity";
assertEquals(EXPECTED_CSS_PROPERTY_FAIL_MESSAGE, expectedValue, webElement.getCssValue(expectedProperty));
assertFalse(HIDDEN_ELEMENT_IS_DISPLAYED_FAIL_MESSAGE, webElement.isDisplayed());
}