下面列出了怎么用org.openqa.selenium.support.ui.Select的API类实例代码及写法,或者点击链接到github查看源代码。
static void removeRedundantScopes(Select select, WebElement button, Collection<String> scopes) {
boolean someRemoved = false;
select.deselectAll();
for (String scope : getSelectValues(select)) {
if (scopes == null // if scopes not provided, remove all
|| !scopes.contains(scope)) { // if scopes provided, remove only the redundant
select.selectByVisibleText(scope);
someRemoved = true;
}
}
if (someRemoved) {
waitUntilElement(button).is().enabled();
button.click();
}
}
@Test
public void test02definePreisModel() throws Exception {
tester.visitPortal(PortalPathSegments.DEFINE_PREICEMODEL);
Select dropdownServiceName = new Select(tester.getDriver().findElement(
By.id(PortalHtmlElements.DEFINE_PRICEMODEL_DROPDOWN_SERVICENAME)));
dropdownServiceName
.selectByVisibleText(PlaygroundSuiteTest.marketServiceName);
tester.waitForElementVisible(
By.id(PortalHtmlElements.DEFINE_PRICEMODEL_BUTTON_SAVE), 10);
if (!tester.getDriver().findElement(By.id(
PortalHtmlElements.DEFINE_PRICEMODEL_CHECKBOX_FREE_OF_CHARGE))
.isSelected()) {
tester.clickElement(
PortalHtmlElements.DEFINE_PRICEMODEL_CHECKBOX_FREE_OF_CHARGE);
}
tester.waitForElementVisible(
By.id(PortalHtmlElements.DEFINE_PRICEMODEL_BUTTON_SAVE), 10);
tester.clickElement(PortalHtmlElements.DEFINE_PRICEMODEL_BUTTON_SAVE);
assertTrue(tester.getExecutionResult());
}
@Test
public void testFontSize() throws Exception {
try {
createNewNote();
waitForParagraph(1, "READY");
Float height = Float.valueOf(driver.findElement(By.xpath("//div[contains(@class,'ace_content')]"))
.getCssValue("height").replace("px", ""));
for (Integer newFontSize = 10; newFontSize <= 20; newFontSize++) {
clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']"));
String visibleText = newFontSize.toString();
new Select(driver.findElement(By.xpath(getParagraphXPath(1)
+ "//ul/li/a/select[(@ng-model='paragraph.config.fontSize')]"))).selectByVisibleText(visibleText);
Float newHeight = Float.valueOf(driver.findElement(By.xpath("//div[contains(@class,'ace_content')]"))
.getCssValue("height").replace("px", ""));
collector.checkThat("New Font size is : " + newFontSize,
newHeight > height,
CoreMatchers.equalTo(true));
height = newHeight;
}
deleteTestNotebook(driver);
} catch (Exception e) {
handleException("Exception in ParagraphActionsIT while testFontSize ", e);
}
}
@When("^I submit a new user with name: (.*?) age: (\\d+) country: (.*?) state: (.*?) server: (.*?) description: (.*?)$")
public void submitNewUser(final String name, final Integer age, final String country, final String state, final String server, final String description) {
webDriver.findElement(By.id("name")).click();
webDriver.findElement(By.id("name")).clear();
webDriver.findElement(By.id("name")).sendKeys(name);
webDriver.findElement(By.id("age")).clear();
webDriver.findElement(By.id("age")).sendKeys(age.toString());
webDriver.findElement(By.id("state")).clear();
webDriver.findElement(By.id("state")).sendKeys(state);
webDriver.findElement(By.xpath("//input[@name='server'][@value='" + server + "']")).click();
webDriver.findElement(By.id("country")).click();
new Select(webDriver.findElement(By.id("country"))).selectByVisibleText(country);
webDriver.findElement(By.id("description")).click();
webDriver.findElement(By.id("description")).clear();
webDriver.findElement(By.id("description")).sendKeys(description);
webDriver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Description:'])[1]/following::button[1]")).click();
}
@Test
void testSelectItemInDDLMultiSelectNotAdditable()
{
WebElement selectedElement = mock(WebElement.class);
when(selectedElement.isSelected()).thenReturn(true);
when(selectedElement.getAttribute(INDEX)).thenReturn(Integer.toString(1));
Select select = findDropDownListWithParameters(true);
List<WebElement> options = List.of(webElement, selectedElement);
when(select.getOptions()).thenReturn(options);
when(webElementActions.getElementText(webElement)).thenReturn(TEXT);
when(webElementActions.getElementText(selectedElement)).thenReturn("not" + TEXT);
fieldActions.selectItemInDropDownList(select, TEXT, false);
verify(webElementActions).getElementText(webElement);
verify(waitActions).waitForPageLoad();
verify(softAssert).assertTrue(ITEMS_WITH_THE_TEXT_TEXT_ARE_SELECTED_FROM_A_DROP_DOWN,
true);
}
@Test
public void test24() throws Exception {
driver.get(baseUrl + "/");
driver.get(baseUrl + "/ImportUrl.html");
driver.findElement(By.id("url")).clear();
driver.findElement(By.id("url")).sendKeys("http://0.0.0.0:11185/datasets/iris.csv");
driver.findElement(By.id("key")).clear();
driver.findElement(By.id("key")).sendKeys("iris22.csv");
driver.findElement(By.xpath("(//button[@onclick='query_submit()'])[2]")).click();
driver.findElement(By.linkText("iris22.csv")).click();
driver.findElement(By.linkText("Parse into hex format")).click();
driver.findElement(By.cssSelector("button.btn.btn-primary")).click();
driver.get(baseUrl + "/GBM.query?key=iris22.hex");
driver.findElement(By.id("source")).clear();
driver.findElement(By.id("source")).sendKeys("iris22.hex");
driver.findElement(By.id("destination_key")).clear();
driver.findElement(By.id("destination_key")).sendKeys("");
new Select(driver.findElement(By.id("vresponse"))).selectByVisibleText("class");
driver.findElement(By.xpath("(//button[@onclick='query_submit()'])[2]")).click();
}
/**
* Add a new asset
*
* @param driver WebDriver instance
* @param baseUrl base url of the server
* @param assetType asset type
* @param assetName asset name
* @param version version
*/
public static void addNewAsset(WebDriver driver, String baseUrl, String assetType, String assetName, String version, String category, String url, String description) {
driver.get(baseUrl + "/publisher/assets/" + assetType + "/list");
WebDriverWait wait = new WebDriverWait(driver, MAX_POLL_COUNT);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Add"+assetType)));
driver.findElement(By.id("Add"+assetType)).click();
//driver.get(baseUrl+PUBLISHER_GADGET_CREATE_PAGE);
driver.findElement(By.name("overview_name")).clear();
driver.findElement(By.name("overview_name")).sendKeys(assetName);
driver.findElement(By.name("overview_version")).clear();
driver.findElement(By.name("overview_version")).sendKeys(version);
if(!category.equals("")){
new Select(driver.findElement(By.name("overview_category"))).selectByVisibleText(category);
}
driver.findElement(By.name("overview_url")).clear();
driver.findElement(By.name("overview_url")).sendKeys(url);
driver.findElement(By.name("overview_description")).clear();
driver.findElement(By.name("overview_description")).sendKeys(description);
driver.findElement(By.name("images_thumbnail")).sendKeys(FrameworkPathUtil.getReportLocation()
+"/../src/test/resources/images/thumbnail.jpg");
driver.findElement(By.name("images_banner")).sendKeys(FrameworkPathUtil.getReportLocation()
+"/../src/test/resources/images/banner.jpg");
driver.findElement(By.id("btn-create-asset")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Add"+assetType)));
}
@Override
public String getValueFromHTMLVisible(Session session, Identifier identifier) {
String result = null;
AnswerItem answer = this.getSeleniumElement(session, identifier, true, false);
if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
WebElement webElement = (WebElement) answer.getItem();
if (webElement != null) {
if (webElement.getTagName().equalsIgnoreCase("select")) {
Select select = (Select) webElement;
result = select.getFirstSelectedOption().getText();
} else if (webElement.getTagName().equalsIgnoreCase("option") || webElement.getTagName().equalsIgnoreCase("input")) {
result = webElement.getAttribute("value");
} else {
result = webElement.getText();
}
}
}
return result;
}
@Test
public void testHolidayCheer() {
driver.get(CHARITY_URL);
wait.until(ExpectedConditions.presenceOfElementLocated(donationAmt)).sendKeys(DONATION_AMT);
driver.findElement(donorEmail).sendKeys(EMAIL);
driver.findElement(donorFirstName).sendKeys(FIRST_NAME);
driver.findElement(donorLastName).sendKeys(LAST_NAME);
driver.findElement(donorStreet).sendKeys(STREET);
driver.findElement(donorCity).sendKeys(CITY);
new Select(driver.findElement(donorCountry)).selectByValue(COUNTRY_CODE);
new Select(driver.findElement(donorState)).selectByValue(STATE_CODE);
driver.findElement(donorPostalCode).sendKeys(POSTAL_CODE);
driver.findElement(donorPhone).sendKeys(PHONE);
driver.findElement(donorCardName).sendKeys(CARD_NAME);
driver.findElement(donorCardNumber).sendKeys(CARD_NUMBER);
driver.findElement(donorCVV2).sendKeys(CVV2);
new Select(driver.findElement(donorCardType)).selectByValue(CARD_TYPE);
new Select(driver.findElement(donorCardMonth)).selectByValue(CARD_MONTH);
new Select(driver.findElement(donorCardYear)).selectByValue(CARD_YEAR);
driver.findElement(submitDonation).click();
}
@Test(groups = "wso2.cep", description = "verify adding an execution plan via management-console UI")
public void testAddExecutionPlan() throws Exception {
driver.get(getLoginURL());
driver.findElement(By.id("txtUserName")).clear();
driver.findElement(By.id("txtUserName")).sendKeys(cepServer.getContextTenant().getContextUser().getUserName());
driver.findElement(By.id("txtPassword")).clear();
driver.findElement(By.id("txtPassword")).sendKeys(cepServer.getContextTenant().getContextUser().getPassword());
driver.findElement(By.cssSelector("input.button")).click();
driver.findElement(By.linkText("Execution Plans")).click();
driver.findElement(By.linkText("Add Execution Plan")).click();
driver.findElement(By.cssSelector("option[value=\"inStream:1.0.0\"]")).click();
driver.findElement(By.id("importedStreamAs")).clear();
driver.findElement(By.id("importedStreamAs")).sendKeys("inStream");
driver.findElement(By.cssSelector("input.button")).click();
driver.findElement(By.xpath("//table[@id='eventProcessorAdd']/tbody/tr[2]/td/table/tbody/tr[4]/td/table/tbody/tr/td/div/div[6]/div/div/div/div/div[5]/div[11]/pre")).click();
driver.findElement(By.id("exportedStreamValueOf")).clear();
driver.findElement(By.id("exportedStreamValueOf")).sendKeys("outStream");
new Select(driver.findElement(By.id("exportedStreamId"))).selectByVisibleText("outStream:1.0.0");
driver.findElement(By.cssSelector("#exportedStreamId > option[value=\"outStream:1.0.0\"]")).click();
driver.findElement(By.id("exportedStreamId")).click();
new Select(driver.findElement(By.id("exportedStreamId"))).selectByVisibleText("outStream:1.0.0");
driver.findElement(By.cssSelector("#exportedStreamId > option[value=\"outStream:1.0.0\"]")).click();
driver.findElement(By.xpath("//input[@value='Export']")).click();
driver.findElement(By.cssSelector("td.buttonRow > input[type=\"button\"]")).click();
driver.close();
}
@Test
public void testWidth() throws Exception {
try {
createNewNote();
waitForParagraph(1, "READY");
collector.checkThat("Default Width is 12 ",
driver.findElement(By.xpath("//div[contains(@class,'col-md-12')]")).isDisplayed(),
CoreMatchers.equalTo(true));
for (Integer newWidth = 1; newWidth <= 11; newWidth++) {
clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']"));
String visibleText = newWidth.toString();
new Select(driver.findElement(By.xpath(getParagraphXPath(1)
+ "//ul/li/a/select[(@ng-model='paragraph.config.colWidth')]"))).selectByVisibleText(visibleText);
collector.checkThat("New Width is : " + newWidth,
driver.findElement(By.xpath("//div[contains(@class,'col-md-" + newWidth + "')]")).isDisplayed(),
CoreMatchers.equalTo(true));
}
deleteTestNotebook(driver);
} catch (Exception e) {
handleException("Exception in ParagraphActionsIT while testWidth ", e);
}
}
@Test
public void test03definePublishOption() throws Exception {
tester.visitPortal(PortalPathSegments.DEFINE_PUBLISHOPTION);
tester.waitForElement(By.id(
PortalHtmlElements.DEFINE_PUBLISH_OPTION_DROPDOWN_SERVICENAME),
10);
Select dropdownServiceName = new Select(tester.getDriver().findElement(
By.id(PortalHtmlElements.DEFINE_PUBLISH_OPTION_DROPDOWN_SERVICENAME)));
dropdownServiceName
.selectByVisibleText(PlaygroundSuiteTest.marketServiceName);
Select dropdownMarketplace = new Select(tester.getDriver().findElement(
By.id(PortalHtmlElements.DEFINE_PUBLISH_OPTION_DROPDOWN_MARKETPLACE)));
dropdownMarketplace.selectByValue(PlaygroundSuiteTest.supplierOrgId);
tester.waitForElementVisible(
By.id(PortalHtmlElements.DEFINE_PUBLISH_OPTION_BUTTON_SAVE),
10);
tester.clickElement(
PortalHtmlElements.DEFINE_PUBLISH_OPTION_BUTTON_SAVE);
assertTrue(tester.getExecutionResult());
}
@Test(groups = "wso2.es.store", description = "Search by newly added asset Version",
dependsOnMethods = "testAddAsset")
public void testESStoreSearchNewlyAddedAssetsVersion() throws Exception {
driver.get(baseUrl + "/store/pages/top-assets");
driver.findElement(By.cssSelector("i.icon-cog")).click();
driver.findElement(By.cssSelector("i.icon-sort-down")).click();
driver.findElement(By.id("search")).click();
driver.findElement(By.name("overview_version")).clear();
driver.findElement(By.name("overview_version")).sendKeys(assetVersion);
new Select(driver.findElement(By.id("overview_category"))).selectByVisibleText(assetCategory);
driver.findElement(By.id("search-button2")).click();
driver.findElementPoll(By.linkText(assetName), 10);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//h4[contains(.,'"+assetName+"')]"), assetName));
assertEquals(assetName, driver.findElement(By.cssSelector("h4")).getText(),
"Newly added gadget is not found in the result of search by version : " +
assetVersion);
wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("img")));
driver.findElement(By.cssSelector("img")).click();
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.linkText("Description"),
"Description"));
assertEquals("Version 1.2.3", driver.findElement(By.cssSelector("small")).getText(),
"Newly added gadget's version is incorrect in the store");
}
static void addMissingScopes(Select select, WebElement button, Collection<String> scopes) {
select.deselectAll();
if (scopes != null) { // if scopes not provided, don't add any
boolean someAdded = false;
for (String scope : getSelectValues(select)) {
if (scopes.contains(scope)) { // if scopes provided, add only the missing
select.selectByVisibleText(scope);
someAdded = true;
}
}
if (someAdded) {
waitUntilElement(button).is().enabled();
button.click();
}
}
}
@Override
public WebElement randomSelect(Element ele)
{
Select select = createSelect(ele);
if(select != null)
{
List<WebElement> options = select.getOptions();
if(CollectionUtils.isNotEmpty(options))
{
int count = options.size();
int index = RandomUtils.nextInt(count);
index = (index == 0 ? 1 : index); //通常第一个选项都是无效的选项
select.selectByIndex(index);
return options.get(index);
}
}
return null;
}
public void assignDeployGroup ( final String deployGroupName )
{
get ( String.format ( "/channel/%s/deployKeys", this.id ) );
final WebElement ele = this.context.findElement ( By.id ( "groupId" ) );
new Select ( ele ).selectByVisibleText ( deployGroupName );
ele.submit ();
}
@Test(groups = "wso2.es.store", description = "Testing category WSO2")
public void testCategoryWSO2() throws Exception {
driver.get(baseUrl + STORE_GADGET_LIST_PAGE);
//google category
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("advanced-search-btn")));
driver.findElement(By.id("advanced-search-btn")).click();
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("search-button2")));
new Select(driver.findElement(By.id("overview_category"))).selectByVisibleText("WSO2");
driver.findElement(By.id("search-button2")).click();
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("div.ctrl-wr-asset")));
assertTrue(isElementPresent(driver,By.cssSelector("div.ctrl-wr-asset")), "WSO2 Category wrong");
}
@Test(groups = "wso2.es.store", description = "Testing category template")
public void testCategoryTemplate() throws Exception {
driver.get(baseUrl + STORE_GADGET_LIST_PAGE);
//google category
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("advanced-search-btn")));
driver.findElement(By.id("advanced-search-btn")).click();
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("search-button2")));
new Select(driver.findElement(By.id("overview_category"))).selectByVisibleText("Templates");
driver.findElement(By.id("search-button2")).click();
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("div.ctrl-wr-asset")));
assertTrue(isElementPresent(driver,By.cssSelector("div.ctrl-wr-asset")), "WSO2 Category wrong");
}
/**
* Search queue subscriptions according to the search criteria.
*
* @param queueNamePattern string pattern of the queue name (* for all)
* @param identifierPattern string pattern of the identifier (* for all)
* @param ownNodeIdIndex index of the node Id in the dropdown the subscriptions belong to
* @return number of subscriptions listed under search result
*/
public int searchQueueSubscriptions(String queueNamePattern, String identifierPattern, int ownNodeIdIndex,
boolean isNameExactMatch, boolean isIdentifierExactMatch) {
WebElement queueNamePatternField = driver.findElement(By.name(UIElementMapper.getInstance()
.getElement("mb.search.queue.name.pattern.tag.name")));
queueNamePatternField.clear();
queueNamePatternField.sendKeys(queueNamePattern);
WebElement queueNameExactMatchField = driver.findElement(
By.name(UIElementMapper.getInstance().getElement("mb.search.queue.name.exactmatch.tag.name")));
// Set the name exact match check box state based on the test input
if (isNameExactMatch != queueNameExactMatchField.isSelected()) {
queueNameExactMatchField.click();
}
WebElement queueIdentifierExactMatchField = driver.findElement(
By.name(UIElementMapper.getInstance().getElement("mb.search.queue.identifier.exactmatch.tag.name")));
// Set the identifier exact match check box state based on the test input
if (isIdentifierExactMatch != queueIdentifierExactMatchField.isSelected()) {
queueIdentifierExactMatchField.click();
}
WebElement queueIdentifierPatternField = driver.findElement(By.name(UIElementMapper.getInstance()
.getElement("mb.search.queue.identifier.pattern.tag.name")));
queueIdentifierPatternField.clear();
queueIdentifierPatternField.sendKeys(identifierPattern);
Select ownNodeIdDropdown = new Select(driver.findElement(By.id(UIElementMapper.getInstance()
.getElement("mb.search.queue.own.node.id.element.id"))));
ownNodeIdDropdown.selectByIndex(ownNodeIdIndex);
driver.findElement(By.xpath(UIElementMapper.getInstance()
.getElement("mb.search.queue.search.button.xpath"))).click();
return getSubscriptionCount();
}
@Test
void testSelectItemInDDLSelectMultiple()
{
Select select = findDropDownListWithParameters(true);
addOptionsToSelect(select, TEXT);
fieldActions.selectItemInDropDownList(select, TEXT, false);
verify(webElementActions).getElementText(webElement);
verify(waitActions).waitForPageLoad();
verify(softAssert).assertTrue(ITEMS_WITH_THE_TEXT_TEXT_ARE_SELECTED_FROM_A_DROP_DOWN,
true);
}
@Test
void testSelectItemInDDLSelectPresentOptionDoesntExist()
{
when(webElement.getTagName()).thenReturn(SELECT);
when(webElement.getAttribute(MULTIPLE)).thenReturn(Boolean.toString(false));
Select select = new Select(webElement);
addOptionsToSelect(select, "anotherOne");
fieldActions.selectItemInDropDownList(select, TEXT, false);
verify(webElementActions).getElementText(webElement);
verify(waitActions).waitForPageLoad();
verify(softAssert).assertTrue(ITEM_WITH_THE_TEXT_TEXT_IS_SELECTED_FROM_A_DROP_DOWN,
false);
}
private Select findDropDownListWithParameters(boolean isMultiple)
{
when(webElement.getTagName()).thenReturn(SELECT);
when(webElement.getAttribute(INDEX)).thenReturn("0");
when(webElement.getAttribute(MULTIPLE)).thenReturn(Boolean.toString(isMultiple));
return new Select(webElement);
}
@Override
protected String _getValue()
{
WebElement currentElement = getElement();
if (currentElement.getTagName() == null)
return null;
String returnValue = null;
switch (currentElement.getTagName().toUpperCase())
{
case "IMG":
returnValue = currentElement.getAttribute("src");
break;
case "INPUT":
returnValue = currentElement.getAttribute("value");
break;
case "SELECT":
returnValue = new Select(currentElement).getFirstSelectedOption().getText();
break;
case "UIATEXTFIELD":
returnValue = currentElement.getAttribute("value");
break;
case "ANDROID.WIDGET.EDITTEXT":
returnValue = currentElement.getAttribute("text");
break;
default:
returnValue = currentElement.getText();
break;
}
return returnValue;
}
@Test
void ifDropDownWithNameExistsSelectNull()
{
Select dropDown = mock(Select.class);
DropdownSteps spy = Mockito.spy(dropdownSteps);
Mockito.lenient().doReturn(dropDown).when(spy).isDropDownWithNameFound(null);
spy.ifDropDownWithNameExists(DROP_DOWN_LIST_NAME, TEXT);
verify(softAssert, never()).assertEquals(SELECTED_OPTION_IN_DROP_DOWN, TEXT, TEXT);
}
@Test
void ifDropDownWithNameExistsSelectedOptionsAreNotPresent()
{
Select dropDown = mock(Select.class);
DropdownSteps spy = Mockito.spy(dropdownSteps);
doReturn(dropDown).when(spy).isDropDownWithNameFound(DROP_DOWN_LIST_NAME);
when(dropDown.getAllSelectedOptions()).thenReturn(List.of());
Mockito.lenient().when(softAssert.assertTrue(SELECTED_OPTIONS_ARE_PRESENT_IN_DROP_DOWN, true))
.thenReturn(Boolean.FALSE);
spy.ifDropDownWithNameExists(DROP_DOWN_LIST_NAME, TEXT);
verify(softAssert, never()).assertEquals(SELECTED_OPTION_IN_DROP_DOWN, TEXT, TEXT);
}
public static Set<String> getSelectValues(Select select) {
Set<String> roles = new HashSet<>();
for (WebElement option : select.getOptions()) {
roles.add(getTextFromElement(option));
}
return roles;
}
@Test(groups = "wso2.cep", description = "Test CSRF issue in event simulator")
public void testCSRF() throws Exception {
boolean testPassed = false;
// Login
driver.get(getLoginURL());
driver.findElement(By.id("txtUserName")).clear();
driver.findElement(By.id("txtUserName")).sendKeys(cepServer.getContextTenant().getContextUser().getUserName());
driver.findElement(By.id("txtPassword")).clear();
driver.findElement(By.id("txtPassword")).sendKeys(cepServer.getContextTenant().getContextUser().getPassword());
driver.findElement(By.cssSelector("input.button")).click();
driver.findElement(By.id("menu-panel-button4")).click();
// Goto Event Simulator page
String pageUrl = backendURL.substring(0, 22) + "/carbon/eventsimulator/index.jsp?";
List<NameValuePair> pageParams = new ArrayList<>();
pageParams.add(new BasicNameValuePair("region", "5"));
pageParams.add(new BasicNameValuePair("item", "event_simulator_menu"));
pageUrl += URLEncodedUtils.format(pageParams, "UTF-8");
driver.get(pageUrl);
// Fill the event field values and click send
Select dropdown = new Select(driver.findElement(By.id("EventStreamID")));
dropdown.selectByVisibleText("TempStream:1.0.0");
driver.findElement(By.id("0")).clear();
driver.findElement(By.id("0")).sendKeys("11");
driver.findElement(By.id("1")).clear();
driver.findElement(By.id("1")).sendKeys("22");
driver.findElement(By.id("2")).clear();
driver.findElement(By.id("2")).sendKeys("33");
driver.findElement(By.xpath("(//input[@value='Send'])[1]")).click();
if("Events is successfully sent".equals(
driver.findElement(By.id("messagebox-info")).findElement(By.tagName("p")).getText())) {
testPassed = true;
}
Assert.assertTrue(testPassed);
driver.close();
}
/**
* selects the first picture with the label <b>orderLabel</b> in the selectbox
*
* @param orderLabel
*/
public void selectPictureWithOrder(String orderLabel) {
By selector = By.cssSelector(SELECTBOX_SELECTOR);
WebElement element = this.getDriver().findElement(selector);
Select select = new Select(element);
select.selectByVisibleText(orderLabel);
}
public void setMetadataType(String mtype) {
if (mtype.equalsIgnoreCase("federation")) {
fluentWait(LARGE);
}
fluentWait(ONE_SEC);
WebElement element = webDriver.findElement(By.className("MetaDataType"));
Select select = new Select(element);
select.selectByVisibleText(mtype);
}
private void deSelect(Select select, String Data, SelectBy selectBy) {
switch (selectBy) {
case Index:
select.deselectByIndex(Integer.parseInt(Data));
break;
case Text:
select.deselectByVisibleText(Data);
break;
case Value:
select.deselectByValue(Data);
break;
}
}