Untitled
raw download clone
JAVA
views 18
,
size 68292 b
package com.intracom.elemental.test.ee.radioplanning;

import java.util.Arrays;
import java.util.List;

import org.jbehave.core.annotations.Then;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;

import com.intracom.elemental.jbehave.Assert;
import com.intracom.elemental.jbehave.selenium.DOMToolkit;
import com.intracom.elemental.jbehave.selenium.MWebDriverWait;
import com.intracom.elemental.jbehave.selenium.SeleniumToolkit;
import com.intracom.elemental.test.ee.security.NetworkAccessDomainAdministrationSteps;

public class RadioPlanningThenSteps {
    @Then("Domain is added successfully with name $domainName in Planning View")
    public void thenDomainIsAdded(String domainName) throws Exception {
        Assert.assertTrue(SeleniumToolkit.domainExistsInPlanningView(domainName));
    }

    @Then("domain $Domain is removed successfully in Planning View")
    public void theDomainIsRemoved(String domainName) throws Exception {
        Assert.assertFalse(SeleniumToolkit.domainExistsInPlanningView(domainName));
    }

    @Then("Domain $Domain is visible in Planning View")
    public void domainIsVisibleInPlanningView(String domainName) throws Exception {
        Assert.assertTrue(SeleniumToolkit.domainExistsInPlanningView(domainName));
    }

    @Then("Domain $Domain is not visible in Planning View")
    public void domainIsNotVisibleInPlanningView(String domainName) throws Exception {
        Assert.assertFalse(SeleniumToolkit.domainExistsInPlanningView(domainName));
    }

    @Then("project $Project exists in Planning View")
    public void projectExistsInPlanningView(String projectName) throws Exception {
        Assert.assertTrue(SeleniumToolkit.projectExistsInPlanningView(projectName));
    }

    @Then("project $Project does not exist in Planning View")
    public void projectDoesNotExistInPlanningView(String projectName) throws Exception {
        Assert.assertFalse(SeleniumToolkit.projectExistsInPlanningView(projectName));
    }

    @Then("checks $Project from dialog Add Site that site setting $SettingsTab with name $NameSettings is not " +
            "available")
    public void thenChecksThatSiteSettingIsNotAvailable(String projectName, String SettingsTab, String NameSettings)
            throws Exception {
        SeleniumToolkit.checkSiteSettingInProject(projectName, SettingsTab, NameSettings, false);
    }

    @Then("checks $Project from dialog Add Site that site setting $SettingsTab with name $NameSettings is " +
            "available")
    public void thenChecksThatSiteSettingIsAvailable(String projectName, String SettingsTab, String NameSettings)
            throws Exception {
        SeleniumToolkit.checkSiteSettingInProject(projectName, SettingsTab, NameSettings, true);
    }

    @Then("checks $Project that the Site $Site display settings are the same with $SiteNewDisplaySettings")
    public void thenChecksThatSiteSettingIsSameWithDefaultSettings(String projectName, String site,
            String defaultSettings)
            throws Exception {
        SeleniumToolkit.checkSettingAreSameWithDefaultInProject(projectName, defaultSettings, site, "Site");
    }

    @Then("checks $Project that the Radio $Radio under $Site display settings are the same with " +
            "$SiteNewDisplaySettings")
    public void thenChecksThatRadioSettingIsSameWithDefaultSettings(String projectName, String radio, String site,
            String defaultSettings)
            throws Exception {
        String nodeName = radio + "," + site;
        SeleniumToolkit.checkSettingAreSameWithDefaultInProject(projectName, defaultSettings, nodeName, "Radio");
    }

    @Then("checks $Project that $TL display settings are the same with $TLNewDisplaySettings")
    public void thenChecksThatTLSettingAreSameWithTLNewDisplaySettings(String projectName, String tl,
            String TLNewdefaultSettings)
            throws Exception {
        SeleniumToolkit.checkSettingAreSameWithDefaultInProject(projectName, TLNewdefaultSettings, tl, "TLs");
    }

    @Then("checks $Project from dialog Add Geo Data that setting $SettingsTab with name $NameSettings is not " +
            "available")
    public void thenChecksThatGeoDataIsNotAvailable(String projectName, String SettingsTab, String NameSettings)
            throws Exception {
        SeleniumToolkit.checkGeoDataSettingInProject(projectName, SettingsTab, NameSettings);
    }

    @Then("site $siteName exists under project $Project")
    public void siteExistsUnderProject(String siteName, String Project) throws Exception {
        final String errorMsg = String.format("Site %s was not found.", siteName);
        Assert.assertTrue(errorMsg, SeleniumToolkit.siteExistsUnderProject(siteName, Project));
    }

    @Then("Object $ObjectType with $Components exist under project $Project in Planning View")
    public void objectTypeWithComponentsExistUnderProject(String objectType, String components, String project)
            throws Exception {
        Assert.assertTrue(SeleniumToolkit.componentsExistUnderProject(objectType, components, project));
    }

    @Then("close project $Project")
    public void thenCloseProject(String projectName) throws Exception {
        SeleniumToolkit.closeProject(projectName);
    }

    @Then("user removes project $Project")
    public void whenUserRemovesProject(String projectName) throws Exception {
        if(SeleniumToolkit.isProjectOpen(projectName)){
            SeleniumToolkit.closeProject(projectName);
        }
        SeleniumToolkit.removeProject(projectName);
    }

    @Then("project $Project is opened successfully")
    public void thenProjectIsOpenedSuccessfully(String project) throws Exception {
        Assert.assertTrue(SeleniumToolkit.isProjectOpen(project));
        // Close project to continue with other scenarios
        SeleniumToolkit.closeProject(project);
        Assert.assertTrue(SeleniumToolkit.tabExists("Planning View", 2));
    }

    @Then("the project file name is not accepted")
    public void thenProjectFileNameIsNotAccepted() throws Exception {
        Assert.assertTrue(DOMToolkit.Dialog.isWarningDialogShown());
        DOMToolkit.Dialog.clickWarningDlgOKButton();
        DOMToolkit.Dialog.clickCancelButton();
    }

    @Then("project $Project is closed successfully")
    public void thenProjectIsClosedSuccessfully(String project) throws Exception {
        Assert.assertFalse(SeleniumToolkit.isProjectOpen(project));
    }

    @Then("site $siteName is removed successfully from project $projectName")
    public void siteIsRemovedFromProject(String siteName, String projectName) throws Exception {
        Assert.assertTrue((SeleniumToolkit
                .findSiteUnderProjectInPlanningView(siteName, projectName, false, false, true)) == null);
    }

    @Then("site $siteName is removed successfully from opened project $projectName")
    public void siteIsRemovedFromOpenedProject(String siteName, String projectName) throws Exception {
        Assert.assertTrue(
                (SeleniumToolkit.findSiteUnderProjectInPlanningView(siteName, projectName, true, true, true)) == null);
    }

    @Then("verify that sites $Sites have attributes $siteAttributes")
    public void thenVerifySitesHaveAttributes(String listSites, String listAttributes) throws Exception {
        // for every site open edit menu and verify given attributes with displayed.
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 10);
        String[] sites = listSites.split(",");
        for (String site : sites) {
            WebElement element = SeleniumToolkit.webDriver
                    .findElement(By.xpath(SeleniumToolkit.xPathRepository.getTreeNodeCellXPath(site)));
            Assert.assertTrue(element != null);
            Actions action = new Actions(SeleniumToolkit.webDriver);
            action.contextClick(element).perform();
            SeleniumToolkit.clickOnMenuItem("Edit");
            String titleXPath = SeleniumToolkit.xPathRepository.getDialogWindowTitleXPath("Edit Site " + site);
            wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(titleXPath)));
            Thread.sleep(500);
            // Verify attributes
            String[] attributes = listAttributes.split(",");
            Assert.assertTrue(attributes.length == 13);
            // 9 inputboxes and 4 dropdown lists
            List<WebElement> elements;
            // When the edit dialog opens the 'Site Name' input box is highlighted and the class is not textItemLite
            // so the found elements should be 9
            elements = SeleniumToolkit.webDriver.findElements(By.xpath("//input[@class = 'textItemLite']"));
            Assert.assertTrue(elements.size() == 9);
            for (int i = 0; i < elements.size(); i++) {
                String expectedAttrValue = attributes[i].trim();
                String actualAttrValue = elements.get(i).getAttribute("value").trim();
                Assert.assertTrue(
                        "Expected attribute with value '" + expectedAttrValue + "' but found '" + actualAttrValue + "'",
                        expectedAttrValue.equalsIgnoreCase(actualAttrValue));
            }
            elements = SeleniumToolkit.webDriver.findElements(By.xpath("//table[@class = 'selectItemLiteControl']"));
            Assert.assertTrue(elements.size() == 4);
            for (int i = 0; i < elements.size(); i++) {
                String expectedAttrValue = attributes[i + 9].trim();
                String actualAttrValue = elements.get(i).getAttribute("textContent").trim();
                Assert.assertTrue(
                        "Expected attribute with value '" + expectedAttrValue + "' but found '" + actualAttrValue + "'",
                        expectedAttrValue.equalsIgnoreCase(actualAttrValue));
            }
            DOMToolkit.Dialog.clickCancelButton();
        }
    }

    @Then("dialog with title $Title is shown")
    public void thenDialogWithTitleIsShown(String title) throws Exception {
        Assert.assertTrue(DOMToolkit.Dialog.isWindowWithHeaderShown(title, 3));
        Thread.sleep(1500);
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 5);

        // if 'Edit Radio', 'Bulk Edit Radio', 'Radio Display', 'Bulk Radio Display',
        // 'Edit Site', 'Bulk Edit Site', 'Site Display', 'Bulk Site Display', 'TL Display Settings'
        // is open click cancel to close it
        String[] windowHeaderContains = { "Edit Radio", "Edit Site", "Radio Display",
                "Site Display", "Coverage Maps", "TL Display Settings" };
        for (String windowHeader : windowHeaderContains) {
            if (DOMToolkit.Dialog.isWindowWithHeaderShown(windowHeader, 3)) {
                DOMToolkit.Dialog.clickCancelButton();
                wait.until(ExpectedConditions.invisibilityOfElementLocated(
                        By.xpath(SeleniumToolkit.xPathRepository.getDialogWindowTitleXPath(windowHeader))));
            }
        }
        // 'Note' dialog is shown -> click OK
        WebElement dialog = DOMToolkit.Dialog.getDialogWithHeaderShown("Note", 3);
        if (dialog != null) {
            String dialogOKBtn = SeleniumToolkit.xPathRepository.getActiveWarningDialogOKButton();
            SeleniumToolkit.getVisibleElement(dialogOKBtn, 8).click();
            wait.until(ExpectedConditions.invisibilityOf(dialog));
        }
        // Close Inventory if is opened
        SeleniumToolkit.closeInventory();
    }

    @Then("interference levels of $Radio in $Project is reset successfully")
    public void thenInterferenceLevelsOfRadioIsReset(String radio, String project) throws Exception {
        // radio example: 'siteA,radioA,TS'
        String[] radioValues = radio.split(",");
        String siteName = radioValues[0];
        String radioName = radioValues[1];
        String radioType = radioValues[2];
        String inventory = null;
        if (radioType.equalsIgnoreCase("PtP"))
            inventory = "PtP/Radios";
        else if (radioType.equalsIgnoreCase("HUB"))
            inventory = "PtMP/HUBs";
        else if (radioType.equalsIgnoreCase("TS"))
            inventory = "PtMP/TSs";
        SeleniumToolkit.openProjectInventory(project, inventory);
        // right-click header -> Columns -> 'Interference Level (Clear Sky)' & 'Interference Level (Rain)'
        String headerXPath = "(//div[contains(@class, 'listGrid')])[last()]//td[contains(@class,'headerButton')]";
        WebElement element = SeleniumToolkit.webDriver.findElement(By.xpath(headerXPath));
        Actions action = new Actions(SeleniumToolkit.webDriver);
        action.contextClick(element).perform();
        SeleniumToolkit.moveOverMenuItem("Columns");
        SeleniumToolkit.clickOnMenuItem("Interference Level (Clear Sky)");
        SeleniumToolkit.clickOnMenuItem("Interference Level (Rain)");
        // close context menu by clicking another element...
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 10);
        wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath("//div[@class='windowBackground']/div[@class='windowHeader']"))).click();
        // find row based on callsign, site name, Interference Level (Clear Sky), Interference Level (Rain)
        String[] columnNames = new String[] { "CallSign", "Site Name", "Interference Level (Clear Sky)",
                "Interference Level (Rain)" };
        String interference = "-200";
        WebElement row = SeleniumToolkit.getReportRow(columnNames,
                new String[] { radioName, siteName, interference, interference }, SeleniumToolkit.ReportType.EVENTS,
                false);
        Assert.assertTrue(row != null);
    }

    @Then("radio $radioName exists under $siteName in project $projectName")
    public void thenRadioIsAdded(String radioName, String siteName, String projectName) throws Exception {
        Assert.assertTrue((SeleniumToolkit.findRadioUnderSiteInProject(radioName, siteName, projectName)) != null);
    }

    @Then("radio $radioName of Site $siteName in Project $projectName does not exist")
    public void thenRadioDoesNotExist(String radio, String site, String project) throws Exception {
        String errorMsg = "Radio " + radio + " exists.";
        Assert.assertTrue(errorMsg, (SeleniumToolkit.findRadioUnderSiteInProject(radio, site, project)) == null);
    }

    @Then("Geo Data $ClutterHeight does not exist in Project $Project Tree View")
    public void thenGeoDataDoesNotExist(String geoData, String project) throws Exception {
        SeleniumToolkit.expandProjectItem(project, "Geo Data");
        String xpath = SeleniumToolkit.xPathRepository.getExactTreeNodeCellXPath(geoData);
        List<WebElement> elements = SeleniumToolkit.webDriver.findElements(By.xpath(xpath));
        Assert.assertTrue("Found Geo Data " + geoData, elements.size() == 0);
    }

    @Then("er is $er and s is $s")
    public void thenErAndSisAutofilled(String er, String s) throws Exception {
        String firstRowErXPath = "(//td[contains(@class,'windowHeaderText')][contains(text(),'Edit Path Profile')"
                + "]/following::table[@class='listTable']/tbody/tr)[1]/td[6]/div[text()='" + er + "']";
        String firstRowSXPath = "(//td[contains(@class,'windowHeaderText')][contains(text(),'Edit Path Profile')"
                + "]/following::table[@class='listTable']/tbody/tr)[1]/td[7]/div[text()='" + s + "']";
        List<WebElement> erElement = SeleniumToolkit.webDriver.findElements(By.xpath(firstRowErXPath));
        Assert.assertTrue("Could not find er with value " + er, erElement.size() == 1);
        List<WebElement> sElement = SeleniumToolkit.webDriver.findElements(By.xpath(firstRowSXPath));
        Assert.assertTrue("Could not find s with value " + s, sElement.size() == 1);
    }

    @Then("every TL Path Profile attribute of row $Row is changed in UI")
    public void thenEveryTLPathProfileAttributeIsChanged(String rows) throws Exception {
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        final String earthElevation = "100";
        final String clutterHeight = "50";
        final String er = "10";
        final String s = "2.345";
        final String reflectivePlane = "Yes";

        // close Edit Path Profile
        String closeXPath = "(" + SeleniumToolkit.xPathRepository.getImgCloseButtonXPath() + ")[last()]";
        SeleniumToolkit.clickElement(closeXPath);
        Thread.sleep(1000);
        // reopen it
        String buttonXPath = SeleniumToolkit.xPathRepository.getActiveDialogButton("Edit Path Profile");
        SeleniumToolkit.clickElement(buttonXPath);

        String[] rowsArray = rows.split(",");
        for (String row : rowsArray) {
            int rowNum = Integer.parseInt(row);
            // check row for cell values
            String earthElevationXPath = "((//td[contains(@class,'windowHeaderText')][contains(text(),'Edit Path "
                    + "Profile')]/following::table[@class='listTable']/tbody/tr)[" + rowNum + "]//td[contains(@class,"
                    + "'cell')]/div)[2]";
            String clutterHeightXPath = "((//td[contains(@class,'windowHeaderText')][contains(text(),'Edit Path "
                    + "Profile')"
                    + "]/following::table[@class='listTable']/tbody/tr)[" + rowNum + "]//td[contains(@class,'cell')"
                    + "]/div)"
                    + "[4]";
            String erXPath = "((//td[contains(@class,'windowHeaderText')][contains(text(),'Edit Path Profile')"
                    + "]/following::table[@class='listTable']/tbody/tr)[" + rowNum + "]//td[contains(@class,'cell')"
                    + "]/div)"
                    + "[6]";
            String sXPath = "((//td[contains(@class,'windowHeaderText')][contains(text(),'Edit Path Profile')"
                    + "]/following::table[@class='listTable']/tbody/tr)[" + rowNum + "]//td[contains(@class,'cell')"
                    + "]/div)"
                    + "[7]";
            String reflectiveXPath = "((//td[contains(@class,'windowHeaderText')][contains(text(),'Edit Path Profile')"
                    + "]/following::table[@class='listTable']/tbody/tr)[" + rowNum + "]//td[contains(@class,'cell')"
                    + "]/div)"
                    + "[8]";

            WebElement cellElement = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(earthElevationXPath)));
            Assert.assertTrue("Earth Elevation should be " + earthElevation + " but was " + cellElement.getText(),
                    cellElement.getText().equalsIgnoreCase(earthElevation));
            cellElement = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(clutterHeightXPath)));
            Assert.assertTrue("Clutter Height should be " + clutterHeight + " but was " + cellElement.getText(),
                    cellElement.getText().equalsIgnoreCase(clutterHeight));
            cellElement = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(erXPath)));
            Assert.assertTrue("er should be " + er + " but was " + cellElement.getText(),
                    cellElement.getText().equalsIgnoreCase(er));
            cellElement = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(sXPath)));
            Assert.assertTrue("σ should be " + s + " but was " + cellElement.getText(),
                    cellElement.getText().equalsIgnoreCase(s));
            cellElement = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(reflectiveXPath)));
            Assert.assertTrue("Reflective Plane should '" + reflectivePlane + "' but was " + cellElement.getText(),
                    cellElement.getText().equalsIgnoreCase(reflectivePlane));
        }

        // close dialogs
        String[] windowHeaderContains = { "Edit Path Profile", "Edit PtP TL" };
        for (String windowHeader : windowHeaderContains) {
            if (DOMToolkit.Dialog.isWindowWithHeaderShown(windowHeader, 10)) {
                SeleniumToolkit.clickElement(closeXPath);
                Thread.sleep(1000);
            }
        }
    }

    @Then("Clutter Height $ClutterHeight height source attribute is changed successfully from project $Project")
    public void thenClutterHeightSourceIsChanged(String clutterHeight, String project) throws Exception {
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        String windowXPath = SeleniumToolkit.xPathRepository.getDialogWindowTitleXPath("Edit Clutter Data");
        String colNum = "8";
        String colColor = "#4f6228";
        String colName = "Forest";
        String colHeightSource = "User";
        String colHeight = "1234";
        String rowXPathFormat = "//table[@class='listTable']//td/div[text()='%s']/../../td/div[text()='%s']/../."
                + "./td/div[text()='%s']/../../td/div[text()='%s']/../../td/div[text()='%s']";
        String rowXPath = String.format(rowXPathFormat, colNum, colColor, colName, colHeightSource, colHeight);
        SeleniumToolkit.expandProjectItem(project, "Geo Data");
        // Right-click clutter height node and click 'Edit Clutter Type'
        String clutterXPath = SeleniumToolkit.xPathRepository.getExactTreeNodeCellXPath(clutterHeight);
        SeleniumToolkit.rightClickOnWebElementAndClickOnMenu(clutterXPath, "Edit Clutter Type");
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(windowXPath)));
        WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(rowXPath)));
        Assert.assertTrue(element != null);
        DOMToolkit.Dialog.clickOKButton();
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(windowXPath)));
    }

    /**
     * This step will click the X button of all windowBackground windows.
     * If there is a window with no X button it will fail.
     *
     * @throws Exception
     */
    @Then("close all windows")
    public void theCloseAllWindows() throws Exception {
        final String lastWindowXPath = "(//div[contains(@class, 'windowBackground')])[last()]";
        final String allWindowXPath = "//div[contains(@class, 'windowBackground')]";
        final String closeXPath = "(" + SeleniumToolkit.xPathRepository.getImgCloseButtonXPath() + ")[last()]";

        List<WebElement> windowElements = SeleniumToolkit.webDriver_findElements(By.xpath(allWindowXPath));
        if (windowElements == null || windowElements.isEmpty()) {
            return;
        }

        for (int i = windowElements.size() - 1; i >= 0; i--) {
            List<WebElement> webElements = windowElements.get(i).findElements(By.xpath(lastWindowXPath));
            if (webElements != null && !webElements.isEmpty()) {
                WebElement element = webElements.get(webElements.size() - 1);
                if (element.isDisplayed()) {
                    SeleniumToolkit.clickElement(closeXPath);
                    Thread.sleep(1000);
                }
            }
        }
    }

    @Then("Physical Radios $PhysicalRadios are created under Logical Radio $LogicalRadio of Sites $Sites of project "
            + "$Project in $TypeView View")
    public void thenPhysicalRadiosAreCreated(String physicalRadios, String logicalRadio, String sites, String project,
            String typeView) throws Exception {
        String[] sitesArray = sites.split(",");
        // Check that Physical radios also exist in Inventory
        if (typeView.equalsIgnoreCase("Inventory")) {
            SeleniumToolkit.openProjectInventory(project, "PtP/Radios");
            String[] columnNames = { "CallSign", "Site Name" };
            for (String radio : physicalRadios.split(",")) {
                for (String site : sitesArray) {
                    String[] columnValues = { radio, site };
                    WebElement radioRow = SeleniumToolkit
                            .getReportRow(columnNames, columnValues, SeleniumToolkit.ReportType.EVENTS,
                                    false);
                    Assert.assertTrue("Could not find Physical Radio in Inventory " + radio, radioRow != null);
                }
            }
            SeleniumToolkit.closeInventory();
        }

        for (String site : sitesArray) {
            Actions action = new Actions(SeleniumToolkit.webDriver);
            WebElement element = SeleniumToolkit
                    .findRadioUnderSiteInProject(logicalRadio, site, project);
            action.doubleClick(element).perform();
            for (String radio : physicalRadios.split(",")) {
                WebElement radioElem = SeleniumToolkit.webDriver
                        .findElement(By.xpath(SeleniumToolkit.xPathRepository.getExactTreeNodeCellXPath(radio)));
                Assert.assertTrue("Could not find Physical Radio " + radio, radioElem != null);
            }
        }
    }

    @Then("Physical Radios $PhysicalRadios are deleted under Logical Radio $LogicalRadio of Sites $Sites of project "
            + "$Project in $TypeView View")
    public void thenPhysicalRadiosAreDeleted(String physicalRadios, String logicalRadio, String sites, String project,
            String typeView) throws Exception {
        String[] sitesArray = sites.split(",");
        // Check that Physical radios do not exist in Inventory
        if (typeView.equalsIgnoreCase("Inventory")) {
            SeleniumToolkit.openProjectInventory(project, "PtP/Radios");
            String[] columnNames = { "CallSign", "Site Name" };
            for (String radio : physicalRadios.split(",")) {
                for (String site : sitesArray) {
                    String[] columnValues = { radio, site };
                    WebElement radioRow = SeleniumToolkit
                            .getReportRow(columnNames, columnValues, SeleniumToolkit.ReportType.EVENTS,
                                    false);
                    Assert.assertTrue("Found Physical Radio in Inventory " + radio, radioRow == null);
                }
            }
            SeleniumToolkit.closeInventory();
        }

        for (String site : sitesArray) {
            Actions action = new Actions(SeleniumToolkit.webDriver);
            WebElement element = SeleniumToolkit
                    .findRadioUnderSiteInProject(logicalRadio, site, project);
            action.doubleClick(element).perform();
            for (String radio : physicalRadios.split(",")) {
                List<WebElement> radioElem = SeleniumToolkit.webDriver
                        .findElements(By.xpath(SeleniumToolkit.xPathRepository.getExactTreeNodeCellXPath(radio)));
                Assert.assertTrue("Found Physical Radio " + radio, radioElem.size() == 0);
            }
        }

    }

    @Then("Physical TLs $PhysicalTLS are deleted under $LogicalTL of project $Project in $TypeView View")
    public void thenPhysicalTLsAreDeleted(String physicalTLs, String logicalTL, String project, String typeView)
            throws Exception {
        // Check that Physical TLs do not exist in Inventory
        if (typeView.equalsIgnoreCase("Inventory")) {
            SeleniumToolkit.openProjectInventory(project, "PtP/TLs");
            String[] columnNames = { "CallSign", "A End Site Name", "Z End Site Name" };
            for (String tl : physicalTLs.split(",")) {
                String[] columnValues = tl.split("-");
                WebElement tlRow = SeleniumToolkit
                        .getReportRow(columnNames, columnValues, SeleniumToolkit.ReportType.EVENTS,
                                false);
                Assert.assertTrue("Found Physical Radio in Inventory " + tl, tlRow == null);
            }
            SeleniumToolkit.closeInventory();
        }

        SeleniumToolkit.expandProjectItem(project, "TLs");
        Actions action = new Actions(SeleniumToolkit.webDriver);
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        WebElement logicalTLElement = wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath(SeleniumToolkit.xPathRepository.getExactTreeNodeCellXPath(logicalTL))));
        Thread.sleep(500);
        action.doubleClick(logicalTLElement).perform();

        for (String phyTL : physicalTLs.split(",")) {
            List<WebElement> phyTLElements = SeleniumToolkit.webDriver
                    .findElements(By.xpath(SeleniumToolkit.xPathRepository.getExactTreeNodeCellXPath(phyTL)));
            Assert.assertTrue("Found Physical TL " + phyTL, phyTLElements.size() == 0);
        }
    }

    @Then("Physical TLs $PhysicalTLs are created under $LogicalTL of project $Project in $TypeView View")
    public void thenPhysicalTLsAreCreated(String physicalTLs, String logicalTL, String project, String typeView)
            throws Exception {
        // Check that Physical TLs also exist in Inventory
        if (typeView.equalsIgnoreCase("Inventory")) {
            SeleniumToolkit.openProjectInventory(project, "PtP/TLs");
            String[] columnNames = { "CallSign", "A End Site Name", "Z End Site Name" };
            for (String tl : physicalTLs.split(",")) {
                String[] columnValues = tl.split("-");
                WebElement tlRow = SeleniumToolkit
                        .getReportRow(columnNames, columnValues, SeleniumToolkit.ReportType.EVENTS,
                                false);
                Assert.assertTrue("Could not find Physical Radio in Inventory " + tl, tlRow != null);
            }
            SeleniumToolkit.closeInventory();
        }

        SeleniumToolkit.expandProjectItem(project, "TLs");
        Actions action = new Actions(SeleniumToolkit.webDriver);
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        WebElement logicalTLElement = wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath(SeleniumToolkit.xPathRepository.getExactTreeNodeCellXPath(logicalTL))));
        Thread.sleep(500);
        action.doubleClick(logicalTLElement).perform();

        for (String phyTL : physicalTLs.split(",")) {
            List<WebElement> phyTLElements = SeleniumToolkit.webDriver
                    .findElements(By.xpath(SeleniumToolkit.xPathRepository.getExactTreeNodeCellXPath(phyTL)));
            Assert.assertTrue("Could not find Physical TL " + phyTL, phyTLElements.size() == 1);
        }
    }

    @Then("TLs $TLs from $Project does not exist")
    public void thenTLDoesNotExist(String tls, String project) throws Exception {
        SeleniumToolkit.expandProjectItem(project, "TLs");
        for (String tl : tls.split(",")) {
            String errorMsg = "TL " + tl + " exists.";
            String tlXPath = SeleniumToolkit.xPathRepository.getExactTreeNodeCellXPath(tl);
            Assert.assertTrue(errorMsg, SeleniumToolkit.webDriver.findElements(By.xpath(tlXPath)).size() == 0);
        }
    }

    @Then("TLs $TLs in project $Project are activated successfully")
    public void thenTlsAreActivated(String tls, String project) throws Exception {
        if (SeleniumToolkit.isProjectOpen(project)) { // when used from Inventory View
            SeleniumToolkit.expandProjectItem(project, "TLs");
        }

        String[] tlsArray = tls.split(",");
        for (String tl : tlsArray) {
            String tlActiveXPath = SeleniumToolkit.xPathRepository.getActiveTLXPath(tl);
            WebElement element = SeleniumToolkit.webDriver.findElement(By.xpath(tlActiveXPath));
            Assert.assertTrue("Could not find Active TL " + tl, element != null);
        }
    }

    @Then("TLs $TLs in project $Project are deactivated successfully")
    public void thenTlsAreDeactivated(String tls, String project) throws Exception {
        if (SeleniumToolkit.isProjectOpen(project)) { // when used from Inventory View
            SeleniumToolkit.expandProjectItem(project, "TLs");
        }

        String[] tlsArray = tls.split(",");
        for (String tl : tlsArray) {
            String xpath = SeleniumToolkit.xPathRepository.getDeactivatedTLXPath(tl);
            WebElement element = SeleniumToolkit.webDriver.findElement(By.xpath(xpath));
            Assert.assertTrue("Could not find Deactivated TL " + tl, element != null);
        }
    }

    @Then("Geo Data $GeoData is deactivated from project $Project")
    public void thenGeoDataIsDeactivated(String geoData, String project) throws Exception {
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        SeleniumToolkit.expandProjectItem(project, "Geo Data");
        // element should exists with deactivated icon
        String deactivatedGeodataXPath = SeleniumToolkit.xPathRepository
                .getDectivatedClutterHeightXPath(project, geoData);
        if (SeleniumToolkit.isProjectOpen(project)) {
            deactivatedGeodataXPath = deactivatedGeodataXPath
                    .replace("tr/td[string()='Whole Network']/../following-sibling::", "");
        }
        WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(deactivatedGeodataXPath)));
        Assert.assertTrue("Deactivated Geo Data " + geoData + " not found", element != null);
    }

    @Then("Geo Data $GeoData is activated from project $Project")
    public void thenGeoDataIsActivated(String geoData, String project) throws Exception {
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        // Expand GeoData
        SeleniumToolkit.expandProjectItem(project, "Geo Data");
        // element should exists with activated icon
        String activeClutterHeightXPath = SeleniumToolkit.xPathRepository.getActiveClutterHeightXPath(project, geoData);
        if (SeleniumToolkit.isProjectOpen(project)) {
            activeClutterHeightXPath = activeClutterHeightXPath
                    .replace("tr/td[string()='Whole Network']/../following-sibling::", "");
        }
        WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(activeClutterHeightXPath)));
        Assert.assertTrue("Activated Geo Data " + geoData + " not found", element != null);
    }

    @Then("clutter height of project $Project is $Height")
    public void thenClutterHeightIs(String project, String height) throws Exception {
        final String site = "IRFPTPB";
        final String clutterHeight = "Clutter Height: " + height.trim();
        final String clutterType = "Clutter Type: 9 - Park/Wood";
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        Actions actions = new Actions(SeleniumToolkit.webDriver);
        boolean isProjectOpen = SeleniumToolkit.isProjectOpen(project);
        if (!isProjectOpen) {
            SeleniumToolkit.openProject(project);
        }
        SeleniumToolkit.expandProjectItem(project, "Sites");
        WebElement siteElement = SeleniumToolkit.findSiteUnderProjectInPlanningView(site, project, isProjectOpen);
        SeleniumToolkit.selectItems(Arrays.asList(siteElement));
        SeleniumToolkit.clickOnMenuButton(SeleniumToolkit.MainMenuButton.FindInMapPlanningView);

        String labelXPath = "//*[@id='EMS=EMS/TelecomEMS,PlanningProject=AutoTestsed01,PlanningSite=IRFPTPB_label']";
        WebElement labelElement = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(labelXPath)));
        actions.click(labelElement).moveByOffset(0, 30).build().perform();

        String xpath = "//div[@class='toolStrip']//div[@class='staticTextItem' and string()='" + clutterType + "']";
        WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));
        Assert.assertTrue(element != null);
        xpath = "//div[@class='toolStrip']//div[@class='staticTextItem' and string()='" + clutterHeight + "']";
        element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));
        Assert.assertTrue(element != null);
    }

    @Then("A End and Z End Radios of TL $LogicalTL of project $Project have 'Diversity Frequency' in Tx/Rx Tab")
    public void thenAandZEndRadiosHaveDiversityFrequency(String logicalTL, String project) throws Exception {
        if (SeleniumToolkit.isProjectOpen(project)) { // when used from Inventory View
            SeleniumToolkit.expandProjectItem(project, "TLs");
        }

        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        Actions action = new Actions(SeleniumToolkit.webDriver);
        WebElement element = wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath(SeleniumToolkit.xPathRepository.getActiveTLXPath(logicalTL))));
        action.contextClick(element).perform();
        SeleniumToolkit.clickOnMenuItem("Edit");
        // click Edit A End
        wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath(SeleniumToolkit.xPathRepository.getActiveDialogButton("Edit A End"))))
                .click();
        // check that 'Diversity Frequency' exists in tab Tx/Rx
        String diversityFreqXPath = "//td[@class='groupLabel' and text()='Diversity Frequency']/../../../../."
                + "./following-sibling::div[1]";
        WebElement diversityElement = SeleniumToolkit.getVisibleElement(diversityFreqXPath, 10);
        Assert.assertTrue("Could not find 'Diversity Frequency' in Tx/Rx tab", diversityElement != null);
        // Click top Cancel button
        String lastCancelBtnXPath = "(" + SeleniumToolkit.xPathRepository
                .getDialogWindowCancelButtonXPath() + ")[last()]";
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
        // click Edit Z End
        wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath(SeleniumToolkit.xPathRepository.getActiveDialogButton("Edit Z End"))))
                .click();
        // check that 'Diversity Frequency' exists in tab Tx/Rx
        diversityElement = SeleniumToolkit.getVisibleElement(diversityFreqXPath, 10);
        Assert.assertTrue("Could not find 'Diversity Frequency' in Tx/Rx tab", diversityElement != null);
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
    }

    @Then("A End and Z End Radios of TL $LogicalTL of project $Project have 'Diversity Antenna' in Antenna Tab")
    public void thenAandZEndRadiosHaveDiversityDiversityAntenna(String logicalTL, String project) throws Exception {
        if (SeleniumToolkit.isProjectOpen(project)) { // when used from Inventory View
            SeleniumToolkit.expandProjectItem(project, "TLs");
        }

        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        Actions action = new Actions(SeleniumToolkit.webDriver);
        WebElement element = wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath(SeleniumToolkit.xPathRepository.getActiveTLXPath(logicalTL))));
        action.contextClick(element).perform();
        SeleniumToolkit.clickOnMenuItem("Edit");
        // click Edit A End
        wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath(SeleniumToolkit.xPathRepository.getActiveDialogButton("Edit A End"))))
                .click();
        // check that 'Diversity Antenna' exists in tab Antenna Tab
        NetworkAccessDomainAdministrationSteps.clickOnSubTab("Antenna");
        String diversityFreqXPath = "//td[@class='groupLabel' and text()='Diversity Antenna']/../../../../."
                + "./following-sibling::div[1]";
        WebElement diversityElement = SeleniumToolkit.getVisibleElement(diversityFreqXPath, 10);
        Assert.assertTrue("Could not find 'Diversity Antenna' in Antenna tab", diversityElement != null);
        // Click top Cancel button
        String lastCancelBtnXPath = "(" + SeleniumToolkit.xPathRepository
                .getDialogWindowCancelButtonXPath() + ")[last()]";
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
        // click Edit Z End
        wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath(SeleniumToolkit.xPathRepository.getActiveDialogButton("Edit Z End"))))
                .click();
        // check that 'Diversity Antenna' exists in tab Antenna Tab
        NetworkAccessDomainAdministrationSteps.clickOnSubTab("Antenna");
        diversityElement = SeleniumToolkit.getVisibleElement(diversityFreqXPath, 10);
        Assert.assertTrue("Could not find 'Diversity Frequency' in Tx/Rx tab", diversityElement != null);
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
    }
    @Then("user confirms that change of $settings at A End to $value of TL $LogicalTL of project $Project applies to "+
            "Z End")
    public void thenUserConfirmsChangeSettingsChangeOfAEndOfTLApplyToZEnd(String settings, String value,
            String LogicalTL, String project) throws Exception {
        String polarizationHXPath = "//input[ @value='H']";
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 60);
        Actions action = new Actions(SeleniumToolkit.webDriver);
        String windowXPath = SeleniumToolkit.xPathRepository.getDialogWindowTitleXPath("Edit PtP TL " + LogicalTL);
        String polarizationXPath = "//tr/td[@class='formTitle']//label[text()='Polarization']/../."
                + "./following-sibling::td[1]/table//div[contains(@class, 'selectItem')]";
        SeleniumToolkit.expandProjectItem(project, "TLs");
        List<WebElement> element = SeleniumToolkit.webDriver
                .findElements(By.xpath(SeleniumToolkit.xPathRepository.getTreeNodeCellXPath(LogicalTL)));
        SeleniumToolkit.selectItemsAndRightClick(element);
        SeleniumToolkit.clickOnMenuItem("Edit");
        // click Edit A End
        wait.until(ExpectedConditions
                .elementToBeClickable(By.xpath(SeleniumToolkit.xPathRepository.getActiveDialogButton("Edit A End"))))
                .click();
        if (settings.equals("Polarization")) {
            NetworkAccessDomainAdministrationSteps.clickOnSubTab("Antenna");
            // Set Polarization to 'H'
            List<WebElement> polarization = SeleniumToolkit.webDriver.findElements(By.xpath(polarizationHXPath));
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(polarizationHXPath))).click();

            String lastOkBtnXPath = "(" + SeleniumToolkit.xPathRepository
                    .getDialogWindowOKButtonXPath() + ")[last()]";
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastOkBtnXPath))).click();

            WebElement dialog = DOMToolkit.Dialog.getDialogWithHeaderShown("Note", 5);
            Assert.assertTrue(dialog != null);
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastOkBtnXPath))).click();
            // Click top Cancel button
            String lastCancelBtnXPath = "(" + SeleniumToolkit.xPathRepository
                    .getDialogWindowCancelButtonXPath() + ")[last()]";
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
            // click Edit Z End
            wait.until(ExpectedConditions
                    .elementToBeClickable(
                            By.xpath(SeleniumToolkit.xPathRepository.getActiveDialogButton("Edit Z End"))))
                    .click();
            NetworkAccessDomainAdministrationSteps.clickOnSubTab("Antenna");
            // Check Polarization is 'H'
            polarization.clear();
            polarization = SeleniumToolkit.webDriver.findElements(By.xpath(polarizationHXPath));
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(polarizationHXPath))).isSelected();
            Assert.assertTrue("Polarization applied to Z End ", polarization != null );

            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
        }else if (settings.equals("Tx/Rx Frequency")){
            String[] freqArray = value.split(",");
            String TxFreqValue = null;
            String RxFreqValue = null;
            TxFreqValue = freqArray[0];
            RxFreqValue= freqArray[1];

            // Change A End 'Tx/Rx Frequency' to values 38360.5,39368.5
            String TxFreqXPath = "//tr/td//label[contains(text(),'Tx Frequency (MHz)')]/following::" +
                    "tr/td/label[contains(text(),'Rx Frequency (MHz)')]/../../../following::" +
                    "input[@class='textItemLite'][1]";
            String RxFreqXPath = "//tr/td//label[contains(text(),'Tx Frequency (MHz)')]/following::" +
                    "tr/td/label[contains(text(),'Rx Frequency (MHz)')]/../../../following::" +
                    "input[@class='textItemLite'][2]";

            //wait.until(ExpectedConditions.elementToBeClickable(By.xpath(TxFreqXPath))).click();
            WebElement TxFreq = SeleniumToolkit.webDriver_findElement(By.xpath(TxFreqXPath));
            Assert.assertTrue(TxFreq != null);
            TxFreq.clear();
            TxFreq.sendKeys(TxFreqValue);

            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(RxFreqXPath))).click();
            WebElement RxFreq = SeleniumToolkit.webDriver_findElement(By.xpath(RxFreqXPath));
            Assert.assertTrue(RxFreq != null);
            RxFreq.clear();
            RxFreq.sendKeys(RxFreqValue);


            String lastOkBtnXPath = "(" + SeleniumToolkit.xPathRepository
                    .getDialogWindowOKButtonXPath() + ")[last()]";
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastOkBtnXPath))).click();

            WebElement dialog = DOMToolkit.Dialog.getDialogWithHeaderShown("Note", 5);
            Assert.assertTrue(dialog != null);
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastOkBtnXPath))).click();
            // Click top Cancel button
            String lastCancelBtnXPath = "(" + SeleniumToolkit.xPathRepository
                    .getDialogWindowCancelButtonXPath() + ")[last()]";
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
            // click Edit Z End
            wait.until(ExpectedConditions
                    .elementToBeClickable(
                            By.xpath(SeleniumToolkit.xPathRepository.getActiveDialogButton("Edit Z End"))))
                    .click();

            Assert.assertTrue(TxFreq != null);
            //System.out.println(TxFreq.getText());
            //Assert.assertTrue(TxFreq.getText().equalsIgnoreCase(TxFreqValue));

            Assert.assertTrue(RxFreq != null);
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath(lastCancelBtnXPath))).click();
        }
    }


    @Then("radio $Radio in project $Project is deactivated successfully")
    public void thenUserChecksDeactivationRadiosFromTreeView(String Radio, String project) throws Exception {
        if (SeleniumToolkit.isProjectOpen(project)) { // when used from Inventory View
            SeleniumToolkit.expandAllSitesOfProject(project);
        }
        String[] radios = Radio.split("&");
        for (int i = 0; i < radios.length; i++) {
            String[] radioValues = radios[i].split(",");
            final String xpathDeactivated = "//td[contains(@class,'treeCell')]/following-sibling::td[contains(text"
                    + "(),'" + radioValues[1] + "')]/following::tr[1]//span[contains(@style,'"
                    + radioValues[2].toLowerCase() + ".png')]";
            WebElement element = SeleniumToolkit.webDriver_findElement(By.xpath(xpathDeactivated));
            Assert.assertTrue("Could not find radio deactivated", element != null);
        }
    }

    @Then("radio $Radio in project $Project is activated successfully")
    public void thenUserChecksActivationRadiosFromTreeView(String radio, String project) throws Exception {
        if (SeleniumToolkit.isProjectOpen(project)) { // when used from Inventory View
            SeleniumToolkit.expandAllSitesOfProject(project);
        }
        String[] radios = radio.split("&");
        for (int i = 0; i < radios.length; i++) {
            String[] radioValues = radios[i].split(",");
            final String xpathActivated = "//td[contains(@class,'treeCell')]/following-sibling::td[contains(text"
                    + "(),'" + radioValues[1] + "')]/following::tr[1]//span[contains(@style,'"
                    + radioValues[2].toLowerCase() + "_active.png')]";
            WebElement element = SeleniumToolkit.webDriver_findElement(By.xpath(xpathActivated));
            Assert.assertTrue("Could not find radio activated", element != null);
        }
    }

    @Then("radio $Radio in project $Project is isolated from $DeactivatedRadios successfully")
    public void thenUserChecksIsolationRadiosFromTreeView(String radio, String project, String DeactivatedRadios)
            throws Exception {
        String[] radios = radio.split("&");
        String[] deactivatedRadios = DeactivatedRadios.split("&");
        WebElement radioImage = null;
        SeleniumToolkit.expandAllSitesOfProject(project);

        for (int i = 0; i < radios.length; i++) {
            String[] radioValues = radios[i].split(",");
            final String xpathActivated = "//span[contains(@style,'opener_opened.png')]/."
                    + "./following-sibling::td[contains(text(),'" + radioValues[1] + "')]/following::tr[1]//span"
                    + "[contains(@style,'" + radioValues[2].toLowerCase() + "_active.png')]";
            radioImage = SeleniumToolkit.webDriver.findElement(By.xpath(xpathActivated));
            Assert.assertTrue("Radio is not activated", radioImage != null);
        }
        for (int i = 0; i < deactivatedRadios.length; i++) {
            String[] deactivatedRadioValues = deactivatedRadios[i].split(",");
            final String xpathDeactivated = "//span[contains(@style,'opener_opened.png')]/."
                    + "./following-sibling::td[contains(text(),'" + deactivatedRadioValues[1] + "')]/following::tr[1"
                    + "]//span[contains(@style,'" + deactivatedRadioValues[2].toLowerCase() + ".png')]";
            radioImage = SeleniumToolkit.webDriver.findElement(By.xpath(xpathDeactivated));
            Assert.assertTrue("Radio Activated", radioImage != null);
        }
    }

    @Then("radio $Radio in project $Project is deactivated successfully from Inventory View")
    public void thenRadioIsDeactivatedFromInventory(String radio, String projectName) throws Exception {
        String[] radioTypes = radio.split("&&");
        String inventory = null;
        for (int i = 0; i < radioTypes.length; i++) {
            String[] radios = radioTypes[i].split("&");
            String[] radioVal = radios[0].split(",");
            String radioType = radioVal[2];
            if (radioType.equalsIgnoreCase("PtP"))
                inventory = "PtP/Radios";
            else if (radioType.equalsIgnoreCase("HUB"))
                inventory = "PtMP/HUBs";
            else if (radioType.equalsIgnoreCase("TS"))
                inventory = "PtMP/TSs";

            SeleniumToolkit.openProjectInventory(projectName, inventory);
            for (int j = 0; j < radios.length; j++) {
                String[] radioValues = radios[j].split(",");
                String radioName = radioValues[0];
                String siteName = radioValues[1];
                String xpathRadioState = "//td/div[contains(text(),'" + radioName
                        + "')]/../following-sibling::td/div[contains(text(),'" + siteName
                        + "')]/../following-sibling::td/div/span[contains(@class,'checkboxFalseDisabled')]";
                WebElement statusCheckBox = SeleniumToolkit.webDriver_findElement(By.xpath(xpathRadioState));
                Assert.assertTrue("Could not find radio deactivated", statusCheckBox != null);
            }
            SeleniumToolkit.closeInventory();
        }
    }

    @Then("$TsRadio in project $Project changed to $colorFromHub successfully")
    public void thenUserChecksColorTsRadiosFromTreeView(String radio, String project, String color) throws Exception {
        String[] radios = radio.split(",");
        if (SeleniumToolkit.isProjectOpen(project)) {
            SeleniumToolkit.findRadioUnderSiteInProject(radios[0], radios[1], project, true).click();
            SeleniumToolkit.clickOnMenuButton(SeleniumToolkit.MainMenuButton.FindInMapPlanningView);
            SeleniumToolkit.rightClickOnMap();
        } else {
            WebElement radioNode = SeleniumToolkit.findRadioUnderSiteInProject(radios[0], radios[1], project);
            final Actions action = new Actions(SeleniumToolkit.webDriver);
            action.contextClick(radioNode).perform();
        }
        SeleniumToolkit.clickOnMenuItem("Display");
        // Check Stroke Color
        String strokeColorXPath =
                "(//label[text()='Stroke Color']/following::td[contains(@style,'background-color: " + color + "')])"
                        + "[last()]";
        WebElement colorBtn = SeleniumToolkit.webDriver.findElement(By.xpath(strokeColorXPath));
        Assert.assertTrue(colorBtn != null);
        DOMToolkit.Dialog.clickOKButton();
        WebElement dialog = DOMToolkit.Dialog.getDialogWithHeaderShown("Note", 10);
        Assert.assertTrue(dialog != null);
        DOMToolkit.Dialog.clickOKButton();
    }

    @Then("$TsRadio in project $Project changed to $color successfully from Inventory View")
    public void thenUserChecksColorTsRadiosFromInventoryView(String radioCallSignSiteName, String project, String color)
            throws Exception {
        String callSign = radioCallSignSiteName.split(",")[0];
        String siteName = radioCallSignSiteName.split(",")[1];
        String[] columnNames = { "CallSign", "Site Name" };
        WebElement row = SeleniumToolkit.getReportRow(columnNames, new String[] { callSign, siteName },
                SeleniumToolkit.ReportType.EVENTS, false);
        Assert.assertTrue(row != null);
        Actions actions = new Actions(SeleniumToolkit.webDriver);
        actions.contextClick(row).perform();
        SeleniumToolkit.clickOnMenuItem("Display");
        String strokeColorXPath =
                "(//label[text()='Stroke Color']/following::td[contains(@style,'background-color: " + color + "')])"
                        + "[last()]";
        WebElement colorBtn = SeleniumToolkit.webDriver.findElement(By.xpath(strokeColorXPath));
        Assert.assertTrue(colorBtn != null);
        DOMToolkit.Dialog.clickOKButton();
        WebElement dialog = DOMToolkit.Dialog.getDialogWithHeaderShown("Note", 3);
        Assert.assertTrue(dialog != null);
        DOMToolkit.Dialog.clickOKButton();
    }

    @Then("the Project name is not accepted")
    public void thenTheProjectNameIsNotAccepted() throws Exception {
        Thread.sleep(500);
        Assert.assertTrue(SeleniumToolkit.exclamationContains("Name can have all characters except from"));
    }

    @Then("checks $FrequencyValues of $RadioFrequencySettingsTypes for $Radio if exists in Database for "
            + "$ProjectName")
    public static void thenChecksFrequencyValuesFromDatabase(String radioFrequencySettings,
            String radioFrequencySettingsTypes, String radioDetails, String projectName) throws Exception {
        String[] radiosPath = radioDetails.split(",");
        boolean objectsExist = SeleniumToolkit.checkDoubleValuesIfExistInPtRadioTableInDBForSiteRadio(radiosPath[1],
                radiosPath[0], radioFrequencySettings, radioFrequencySettingsTypes, projectName);
        Assert.assertTrue("Frequency settings are not updated correctly ", objectsExist);
    }

    @Then("checks $RadioPolarizationSetting values for $TsRadio if exists in Database for $Project")
    public static void thenChecksPolarizationSettingFromDatabase(String radioPolarizationSetting, String radioDetails,
            String projectName) throws Exception {
        String radioPolarizationSettingValue;
        String[] radiosPath = radioDetails.split(",");
        if (radioPolarizationSetting.equals("V")) {
            radioPolarizationSettingValue = "Vertical";
        } else if (radioPolarizationSetting.equals("C")) {
            radioPolarizationSettingValue = "Circular";
        } else {
            radioPolarizationSettingValue = "Horizontal";
        }
        boolean objectExists = SeleniumToolkit.checkStringValueIfExistInPtRadioTableInDBForSiteRadio(radiosPath[1],
                radiosPath[0], "polarization", radioPolarizationSettingValue, projectName);
        Assert.assertTrue("Frequency settings are not updated correctly ", objectExists);
    }

    @Then("checks if $NameSettings exist in $ColumnName")
    public static void thenChecksIfNameExists(String nameSettings, String columnName) throws Exception {
        String[] nameSettingsArray = nameSettings.split(",");
        boolean found = false;
        for (String nameSetting : nameSettingsArray) {
            found = SeleniumToolkit.reportRowExists(new String[] { columnName }, new String[] { nameSetting });
            if (!found) {
                break;
            }
        }
        // if rows are found
        Assert.assertTrue(found);
        //SeleniumToolkit.closeTab("Radio Planning Settings");
    }

    @Then("remove NameSettings $Settings if exist in $ColumnName for tab $SettingsTab")
    public static void thenRemoveIfNameSettingsExist(String nameSettings, String columnName, String settingsTab)
            throws Exception {
        SeleniumToolkit.openReport("Radio Planning");
        NetworkAccessDomainAdministrationSteps.clickOnSubTab(settingsTab);
        String[] nameSettingsArray = nameSettings.split(",");
        boolean found = false;
        for (String nameSetting : nameSettingsArray) {
            found = SeleniumToolkit.reportRowExists(new String[] { columnName }, new String[] { nameSetting });
            if (found) {
                SeleniumToolkit
                        .clickOnReportCell(new String[] { columnName }, new String[] { nameSetting }, columnName,
                                "CLICK",
                                SeleniumToolkit.ReportType.NORMAL);
                SeleniumToolkit.clickOnMenuButton(SeleniumToolkit.MainMenuButton.Remove);
                final MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 0);
                DOMToolkit.Dialog.clickOKButton();
            }
        }
    }

    @Then("add $FileSettings if NameSettings $NameSettings not exist in $ColumnName for tab $SettingsTab")
    public static void thenAddIfNameSettingsNotExist(String fileSettings, String nameSettings, String columnName,
            String settingsTab)
            throws Exception {
        SeleniumToolkit.openReport("Radio Planning");
        NetworkAccessDomainAdministrationSteps.clickOnSubTab(settingsTab);
        String[] nameSettingsArray = nameSettings.split(",");
        boolean found = false;
        for (String nameSetting : nameSettingsArray) {
            found = SeleniumToolkit.reportRowExists(new String[] { columnName }, new String[] { nameSetting });
        }
        if (!found) {
            if (settingsTab.equalsIgnoreCase("PtP Configuration")) {
                SeleniumToolkit.addPtPConfiguration(fileSettings, settingsTab);
            } else if (settingsTab.equalsIgnoreCase("Site Type") || settingsTab.equalsIgnoreCase("Site Status")) {
                SeleniumToolkit.addSiteSettings(nameSettings, settingsTab);
            } else if (settingsTab.equalsIgnoreCase("Geo Data")) {
                String[] fileSettingsArray = fileSettings.split(",,");
                SeleniumToolkit.addGeoData(fileSettingsArray[0], fileSettingsArray[1], fileSettingsArray[2]);
            } else {
                SeleniumToolkit.addSettingsInRadioPlanning(fileSettings);
            }
        }
    }

    @Then("color Code $colorCode exists in $projectName Settings")
    public static void thenColorSettingExistInProjectSettings(String colorCode, String projectName) throws Exception {
        SeleniumToolkit.openProjectSettings(projectName);
        NetworkAccessDomainAdministrationSteps.clickOnSubTab("DL/UL Map Color Coding");
        List<WebElement> cellNodes = SeleniumToolkit
                .webDriver_findElements(By.xpath("//div[contains(text(),'" + colorCode + "')]"));
        final List<WebElement> colorNodes = SeleniumToolkit.getVisibleElements(cellNodes);
        Assert.assertTrue(colorNodes.size() > 0);
        SeleniumToolkit.closeTab("Project Settings - " + projectName);
    }

    @Then("confirm that no errors exist in PtPConfigurarion")
    public static void thenChecksIfNoErrorsExistInPtPConfiguration() throws Exception {
        for (int i = 1; i < 13; i++) {
            Assert.assertFalse(SeleniumToolkit.errorInPtPConfigurationFound(i));
        }
    }

    @Then("confirm that no more than 4 Active Units are allowed in PtPConfigurarion")
    public static void thenChecksIfNoMoreThan4ActiveUnits() throws Exception {
        Assert.assertTrue(SeleniumToolkit.errorInPtPConfigurationFound(4));
        SeleniumToolkit.closeTab("Radio Planning Settings");
    }

    @Then("confirm that RLA AND XPIC true is not allowed in PtPConfigurarion")
    public static void thenConfirmThatRLAAndXPICTrueNotAllowed() throws Exception {
        // handle warning message 'RLA and XPIC cannot be both true'
        if (DOMToolkit.Dialog.isDialogShown("RLA and XPIC cannot be both true", 5)) {
            DOMToolkit.Dialog.clickOKButton();
        }
    }

    @Then("confirm that $NameSettings does not exist in PtPConfiguration tab")
    public static void thenConfirmThatPtPConfigurationDoesNotExist(String nameSettings) throws Exception {
        Assert.assertFalse(
                SeleniumToolkit.reportRowExists(new String[] { "Config ID" }, new String[] { nameSettings }));
        SeleniumToolkit.closeTab("Radio Planning Settings");
    }

    @Then("user removes $NameSettings from $SettingsTab")
    public void whenUserRemovesNameSettingsFromSettingsTab(String NameSettings, String SettingsTab) throws Exception {
        NetworkAccessDomainAdministrationSteps.clickOnSubTab(SettingsTab);
        SeleniumToolkit.removeSettings(NameSettings, SettingsTab);
    }

    @Then("check if $NameSettings from $SettingsTab removed successfully")
    public static void thenCheckIfNameRemovedSuccessfully(String nameSettings, String settingsTab) throws Exception {
        if (settingsTab.equals("Waveguide")) {
            String[] columnValues = { nameSettings.split(",")[0], nameSettings.split(",")[1] };
            for (int i = 0; i < columnValues.length; i++) {
                Assert.assertFalse(SeleniumToolkit
                        .reportRowExists(new String[] { "Model/Order Code" }, new String[] { columnValues[i] }));
            }
        } else if (settingsTab.equals("Coupler")) {
            String[] columnValues = { nameSettings.split(",")[0], nameSettings.split(",")[1] };
            for (int i = 0; i < columnValues.length; i++) {
                Assert.assertFalse(SeleniumToolkit
                        .reportRowExists(new String[] { "Model" }, new String[] { columnValues[i] }));
            }
        } else if (settingsTab.equals("PtP Configuration")) {
            Assert.assertFalse(
                    SeleniumToolkit.reportRowExists(new String[] { "Config ID" }, new String[] { nameSettings }));
        } else {
            Assert.assertFalse(
                    SeleniumToolkit.reportRowExists(new String[] { "Name" }, new String[] { nameSettings }));
        }

        SeleniumToolkit.closeTab("Radio Planning Settings");
    }

    @Then("reset Database with default Site display settings")
    public void whenResetDatabasewithDefaultSiteDisplaySettings() throws Exception {
        SeleniumToolkit.resetDBWithDefaultSiteDisplaySettings();
    }

    @Then("reset Database with default Radio display settings")
    public void whenResetDatabasewithDefaultRadioDisplaySettings() throws Exception {
        SeleniumToolkit.resetDBWithDefaultRadioDisplaySettings();
    }

    @Then("reset Database with default TL display settings")
    public void whenResetDatabasewithDefaultTLDisplaySettings() throws Exception {
        SeleniumToolkit.resetDBWithDefaultTLDisplaySettings();
    }

    @Then("new Map filter settings $settings do not exist in $projectName Settings")
    public void thenMapFilterSettingsDoNotExist(String settings,String projectName) throws Exception{
        SeleniumToolkit.openProjectSettings(projectName);
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 30);
        NetworkAccessDomainAdministrationSteps.clickOnSubTab("Map Filter");
        String[] value=settings.split(",");
        List<WebElement> textNodes = SeleniumToolkit.webDriver.findElements(By.xpath("//input[contains(@class,'textItem')]"));
        final List<WebElement> visibleTextNodes = SeleniumToolkit.getVisibleElements(textNodes);
        WebElement MinValue = visibleTextNodes.get(0);
        String valueString = MinValue.getAttribute("value");
        Assert.assertFalse(valueString.equals(value[0]));
        WebElement MaxValue = visibleTextNodes.get(1);
        valueString = MaxValue.getAttribute("value");
        Assert.assertFalse(valueString.equals(value[1]));
        SeleniumToolkit.closeTab("Project Settings - " + projectName);
    }

    @Then("new Map filter settings $settings exist in $projectName Settings")
    public void thenMapFilterSettingsExist(String settings,String projectName) throws Exception{
        SeleniumToolkit.openProjectSettings(projectName);
        MWebDriverWait wait = new MWebDriverWait(SeleniumToolkit.webDriver, 30);
        NetworkAccessDomainAdministrationSteps.clickOnSubTab("Map Filter");
        String[] value=settings.split(",");
        List<WebElement> textNodes = SeleniumToolkit.webDriver.findElements(By.xpath("//input[contains(@class,'textItem')]"));
        final List<WebElement> visibleTextNodes = SeleniumToolkit.getVisibleElements(textNodes);
        WebElement MinValue = visibleTextNodes.get(0);
        String valueString = MinValue.getAttribute("value");
        Assert.assertTrue(valueString.equals(value[0]));
        WebElement MaxValue = visibleTextNodes.get(1);
        valueString = MaxValue.getAttribute("value");
        Assert.assertTrue(valueString.equals(value[1]));
        SeleniumToolkit.closeTab("Project Settings - " + projectName);
    }
}
close fullscreen
Login or Register to edit or fork this paste. It's free.