use of org.openqa.selenium.NoSuchElementException in project ats-framework by Axway.
the class RealHtmlSingleSelectList method setValue.
/**
* set the single selection value
*
* @param value the value to select
*/
@Override
@PublicAtsApi
public void setValue(String value) {
new RealHtmlElementState(this).waitToBecomeExisting();
try {
WebElement element = RealHtmlElementLocator.findElement(this);
Select select = new Select(element);
select.selectByVisibleText(value);
} catch (NoSuchElementException nsee) {
throw new SeleniumOperationException("Option with label '" + value + "' not found. (" + this.toString() + ")");
}
UiEngineUtilities.sleep();
}
use of org.openqa.selenium.NoSuchElementException in project ats-framework by Axway.
the class RealHtmlMultiSelectList method setValue.
/**
* select a value
*
* @param value the value to select
*/
@Override
@PublicAtsApi
public void setValue(String value) {
new RealHtmlElementState(this).waitToBecomeExisting();
try {
WebElement element = RealHtmlElementLocator.findElement(this);
Select select = new Select(element);
select.selectByVisibleText(value);
} catch (NoSuchElementException nsee) {
throw new SeleniumOperationException("Option with label '" + value + "' not found. (" + this.toString() + ")");
}
UiEngineUtilities.sleep();
}
use of org.openqa.selenium.NoSuchElementException in project opennms by OpenNMS.
the class ProvisioningNewUIIT method testRequisitionUI.
/**
* Test requisition UI.
*
* @throws Exception the exception
*/
@Test
public void testRequisitionUI() throws Exception {
setImplicitWait(2, TimeUnit.SECONDS);
// Add a new requisition
clickId("add-requisition", false);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("form.bootbox-form > input.bootbox-input")));
enterText(By.cssSelector("form.bootbox-form > input.bootbox-input"), REQUISITION_NAME);
findElementByXpath("//div/button[text()='OK']").click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[text()='" + REQUISITION_NAME + "']")));
// trigger dropdown menu
final String moreActionsButton = "button.btn[uib-tooltip='More actions for requisition " + REQUISITION_NAME + "']";
clickElement(By.cssSelector(moreActionsButton));
// Edit the foreign source
wait.until(ExpectedConditions.elementToBeClickable(By.id("editForeignSource-" + REQUISITION_NAME))).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("ul.nav-tabs > li > a.nav-link")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h4[text()='Foreign Source Definition for Requisition " + REQUISITION_NAME + "']")));
// Add a detector
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("add-detector")));
clickId("add-detector", false);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("form[name='detectorForm']")));
enterText(By.xpath("//form[@name='detectorForm']//input[@ng-model='detector.name']"), NODE_SERVICE);
enterText(By.xpath("//form[@name='detectorForm']//input[@ng-model='detector.class']"), "HTTP");
findElementByXpath("//form[@name='detectorForm']//ul[contains(@class, 'dropdown-menu')]/li/a/strong[text()='HTTP']").click();
waitForDropdownClose();
// Add a parameter to the detector
clickId("add-detector-parameter", false);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[name='paramName']")));
enterText(By.cssSelector("input[name='paramName']"), "po");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@title='port']"))).click();
enterText(By.cssSelector("input[name='paramValue']"), "8980");
//enterText(By.cssSelector("input[name='paramValue']"), Keys.ENTER);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("save-detector"))).click();
waitForModalClose();
enterText(By.cssSelector("input[placeholder='Search/Filter Detectors'][ng-model='filters.detector']"), "HTTP-8980");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[text()='" + NODE_SERVICE + "']")));
// Add a policy to the detector
findElementByCss("#tab-policies .ng-binding").click();
clickId("add-policy", false);
findElementByCss("form[name='policyForm']");
enterText(By.cssSelector("input#name"), "No IPs");
enterText(By.cssSelector("input#clazz"), "Match IP Interface");
enterText(By.cssSelector("input#clazz"), Keys.ENTER);
enterText(By.xpath("(//input[@name='paramValue'])[1]"), "DO_NOT_PERSIST");
enterText(By.xpath("(//input[@name='paramValue'])[1]"), Keys.ENTER);
enterText(By.xpath("(//input[@name='paramValue'])[2]"), "NO_PARAMETERS");
enterText(By.xpath("(//input[@name='paramValue'])[2]"), Keys.ENTER);
clickId("save-policy", false);
waitForModalClose();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[text()='No IPs']")));
// Save foreign source definition
clickId("save-foreign-source", false);
wait.until(ExpectedConditions.not(ExpectedConditions.visibilityOfElementLocated(By.id("save-foreign-source"))));
// Go to the Requisition page
clickId("go-back", false);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h4[text()='Requisition " + REQUISITION_NAME + " (0 defined, 0 deployed)']")));
// Add node to a requisition
clickId("add-node", false);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("nodeLabel"))).clear();
enterText(By.id("nodeLabel"), NODE_LABEL);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("foreignId"))).clear();
enterText(By.id("foreignId"), NODE_FOREIGNID);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("location"))).clear();
saveNode();
// Add an IP Interface
clickId("tab-interfaces", false);
findElementById("add-interface").click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("form[name='intfForm']")));
final By ipaddrBy = By.cssSelector("input#ipAddress");
wait.until(ExpectedConditions.visibilityOfElementLocated(ipaddrBy));
enterText(ipaddrBy, NODE_IPADDR);
// Add a service to the IP Interface
findElementById("add-service").click();
final By xpath = By.cssSelector("input[name='serviceName']");
wait.until(ExpectedConditions.visibilityOfElementLocated(xpath));
Thread.sleep(100);
enterText(xpath, "HTTP-89");
findElementByXpath("//a[@title='HTTP-8980']/strong").click();
// Save the IP interface
clickId("save-interface", false);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[contains(@class,'ng-binding') and text()='" + NODE_IPADDR + "']")));
// Add an asset to the node
clickId("tab-assets", false);
clickId("add-asset", false);
findElementByCss("form[name='assetForm']");
enterText(By.id("asset-name"), "countr");
findElementByXpath("//a[@title='country']/strong").click();
enterText(By.id("asset-value"), "USA");
clickId("save-asset", false);
waitForModalClose();
// Add a category to the node
clickId("tab-categories", false);
clickId("add-category", false);
Thread.sleep(100);
enterText(By.cssSelector("input[name='categoryName']"), NODE_CATEGORY);
findElementByXpath("//a[@title='" + NODE_CATEGORY + "']/strong").click();
saveNode();
// Go to the requisition page
clickId("go-back", false);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[contains(@class,'ng-binding') and text()='" + NODE_LABEL + "']")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[contains(@class,'ng-binding') and text()='" + NODE_FOREIGNID + "']")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//p[contains(@class,'ng-binding') and text()='" + NODE_IPADDR + " (P)']")));
// Synchronize the requisition
clickId("synchronize", false);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".modal-dialog button.btn.btn-primary")));
WebElement modal = findModal();
modal.findElement(By.xpath("//div/button[text()='Yes']")).click();
waitForModalClose();
wait.until(new WaitForNodesInRequisition(REQUISITION_NAME, 1));
wait.until(new WaitForNodesInDatabase(REQUISITION_NAME, 1));
clickId("refresh", false);
clickId("refreshDeployedStats", false);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h4[text()='Requisition " + REQUISITION_NAME + " (1 defined, 1 deployed)']")));
// Go to the requisitions page
clickId("go-back", false);
// Wait until the node has been added to the database, using the ReST API
m_driver.get(getBaseUrl() + "opennms/rest/nodes/" + REQUISITION_NAME + ":" + NODE_FOREIGNID + "/ipinterfaces/" + NODE_IPADDR + "/services/ICMP");
m_driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
try {
for (int i = 0; i < 30; i++) {
try {
final WebElement e = m_driver.findElement(By.xpath("//service/serviceType/name[text()='ICMP']"));
if (e != null) {
break;
}
} catch (Exception e) {
}
m_driver.navigate().refresh();
}
} finally {
m_driver.manage().timeouts().implicitlyWait(LOAD_TIMEOUT, TimeUnit.MILLISECONDS);
}
// Open the nodes list page
m_driver.get(getBaseUrl() + "opennms/");
clickMenuItem("Info", "Nodes", "element/nodeList.htm");
try {
// Disable implicitlyWait
m_driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS);
// If this is the only node on the system, we'll be sent directly to its node details page.
findElementByXpath("//h3[text()='Availability']");
} catch (NoSuchElementException e) {
// If there are multiple nodes, we will be on the node list page, click through to the node
findElementByLink(NODE_LABEL).click();
} finally {
// Restore the implicitlyWait timeout
m_driver.manage().timeouts().implicitlyWait(LOAD_TIMEOUT, TimeUnit.MILLISECONDS);
}
wait.until(ExpectedConditions.elementToBeClickable(By.linkText("ICMP")));
findElementByXpath("//a[contains(@href, 'element/interface.jsp') and text()='" + NODE_IPADDR + "']");
findElementByLink("HTTP-8980");
}
use of org.openqa.selenium.NoSuchElementException in project selenium-tests by Wikia.
the class Elements method getElementByValue.
public static WebElement getElementByValue(List<WebElement> elements, String attribute, String value) {
WebElement foundElement = null;
for (WebElement element : elements) {
String retAttribute = element.getAttribute(attribute);
if ("href".equals(attribute)) {
retAttribute = retAttribute.substring(retAttribute.indexOf("File:") + 5).replace("%20", " ");
if (!element.getAttribute("class").contains("video")) {
retAttribute = retAttribute.substring(0, retAttribute.indexOf('.'));
}
}
if (value.equals(retAttribute)) {
foundElement = element;
PageObjectLogging.log("getElementByValue", "Element with attribute: " + attribute + " with the value: " + value + " is found from the list", true);
break;
}
}
if (foundElement == null) {
throw new NoSuchElementException("Element with attribute: " + attribute + " with the value: " + value + " is not found from the list");
}
return foundElement;
}
use of org.openqa.selenium.NoSuchElementException in project selenium-tests by Wikia.
the class VisualEditorOptionsDialog method getLinkResults.
public List<WebElement> getLinkResults(String searchStr, CategoryResultType resultType) {
String matchCategoryStr = null;
List<WebElement> foundResults = new ArrayList<>();
boolean isMatchingCategory = false;
waitForDialogVisible();
typeCategory(searchStr);
switch(resultType) {
case NEW:
matchCategoryStr = "New category";
break;
case MATCHING:
matchCategoryStr = "Matching categories";
break;
default:
throw new NoSuchElementException("Non-existing result type selected");
}
for (int i = 0; i < categorySuggestions.size(); i++) {
WebElement linkResult = categorySuggestions.get(i);
String elementClassName = linkResult.getAttribute("class");
if (elementClassName.contains(menuSectionItemText)) {
String linkCategory = linkResult.findElement(labelElementBy).getText();
if (linkCategory.equals(matchCategoryStr)) {
isMatchingCategory = true;
} else {
isMatchingCategory = false;
}
} else {
if (isMatchingCategory) {
foundResults.add(linkResult);
}
}
}
if (foundResults.isEmpty()) {
throw new NoSuchElementException("No '" + matchCategoryStr + "' found with the search word: " + searchStr);
}
PageObjectLogging.log("getLinkResults", "Found " + foundResults.size() + " result(s) under '" + matchCategoryStr + "'", true);
return foundResults;
}
Aggregations