Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.dachisgroup.sbi.pages.companyPortfolio;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Iterator;
- import java.util.List;
- import org.openqa.selenium.By;
- import org.openqa.selenium.Dimension;
- import org.openqa.selenium.JavascriptExecutor;
- import org.openqa.selenium.NoSuchElementException;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.support.FindBy;
- import org.openqa.selenium.support.PageFactory;
- import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
- import org.openqa.selenium.support.pagefactory.ElementLocatorFactory;
- import com.dachisgroup.sbi.filtersBlock.AccountFilter;
- import com.dachisgroup.sbi.filtersBlock.BrandsFilter;
- import com.dachisgroup.sbi.filtersBlock.DepartmentsFilter;
- import com.dachisgroup.sbi.filtersBlock.OwnersFilter;
- import com.dachisgroup.sbi.filtersBlock.PlatformsFilter;
- import com.dachisgroup.sbi.filtersBlock.RegionsFilter;
- import com.dachisgroup.sbi.filtersBlock.SubsidiariesFilter;
- import com.dachisgroup.sbi.init.Common;
- import com.dachisgroup.sbi.init.CoreApi;
- import com.dachisgroup.sbi.init.ElementLocators;
- import com.dachisgroup.sbi.pages.ImportSocialAccountsForm;
- import com.dachisgroup.sbi.pages.UserParentPage;
- public class CompanyPortfolioPage extends UserParentPage implements ElementLocators{
- Common common = new Common(driver);
- CoreApi coreApi = new CoreApi();
- /**
- * Define elements on CompanyPortfolioPage.
- */
- @FindBy(id="socialProfile")
- private WebElement socialProfileForm;
- @FindBy(xpath="//dd[@id='Facebook_dd']")
- private WebElement socAccountname;
- @FindBy(xpath="//div[@id='loadAccounts']")
- private WebElement accountLoads;
- @FindBy(css=".sicoalFilterSelected.easy-clearing")
- private WebElement selectedFilters;
- @FindBy(css=".inner.easy-clearing")
- private WebElement cpForm;
- @FindBy(xpath=".//tr[@class='open']")
- private List<WebElement> allListPage;
- @FindBy(xpath="//td[@class='Audience']")
- private List<WebElement> audienceList;
- @FindBy(xpath=".//tbody/tr/td/div/ul[1]/li[2]")
- private List<WebElement> listOfBraindsInDetails;
- @FindBy(xpath=".//*[@id='selectedFilters']/div/ul/li/div")
- private List<WebElement> listOfSelectedFilters;
- @FindBy(xpath="//*[@id='socialProfile']/div/p")
- private WebElement selectedFiltersTitle;
- @FindBy(xpath=".//*/tbody/tr/td/div/ul[1]/li")
- private List<WebElement> listOfAccountDetails;
- @FindBy(xpath=".//*[@id='Associations']/dd[2]/p/span")
- private List <WebElement> regions;
- @FindBy(xpath=".//td[@class='Audience']")
- private List <WebElement> listofAudience;
- @FindBy (xpath="//tr[@class='open']")
- private List <WebElement> listofaccount;
- @FindBy (xpath=".//*[@id='col_audience']")
- private List <WebElement> columnAudience;
- @FindBy(xpath=".//h3[contains(.,'add')]")
- private List <WebElement> listofSoc;
- @FindBy(css=".leftArrow")
- private List <WebElement> listofSocials;
- @FindBy (xpath=".//tbody/tr/td/div/ul/li[3]/span")
- private WebElement ownersSpan;
- @FindBy(css=".name")
- private List<WebElement> listOfFilters;
- @FindBy (xpath="//span[contains(@class,'withoutDisplayName')]")
- private List<WebElement> accountlist;
- @FindBy (css=".user>a")
- private List<WebElement>listofAssigns;
- @FindBy (css=".noneArrow")
- private List <WebElement> emptySocExpand;
- @FindBy(css=".socialProfileList.easy-clearing>h3")
- private WebElement employeeAccountsBlock;
- @FindBy(xpath="//a[@class='profileSettings']")
- private WebElement importExportLink;
- @FindBy(xpath=".//*[@id='socialProfile']/dl/dt/form/ul/li[3]/div")
- private WebElement importExportWindow;
- @FindBy(linkText="Export Results")
- private WebElement exportResultsLink;
- @FindBy(xpath="//ul[@style='display: block;']//a[contains(text(),'Edit')]")
- private WebElement edit;
- @FindBy(linkText="Import Accounts")
- private WebElement importAccountsLink;
- // filters block elements.
- @FindBy(css=".clearAll")
- private WebElement clearAllFiltersHref;
- // @FindBy(css="name:contains('Platforms')")
- @FindBy(xpath="//span[contains(text(), 'Platforms')]")
- private WebElement platformsLink;
- @FindBy(xpath="//form/ul/li/span[contains(text(), 'Brands')]")
- private WebElement brandFormLink;
- @FindBy(xpath="//form/ul/li/span[contains(text(), 'Owners')]")
- private WebElement ownersFormLink;
- @FindBy(xpath="//ul/li/span[contains(text(), 'Regions')]")
- private WebElement regionsFormLink;
- @FindBy(xpath="//form/ul/li/span[contains(text(), 'Subsidiaries')]")
- private WebElement subsidiariesFormLink;
- @FindBy(xpath="//form/ul/li/span[contains(text(), 'Departments')]")
- private WebElement departmentsFormLink;
- @FindBy(xpath="//li[contains(@class,'hover')]//label[not(contains(@for,'country'))]")
- private List<WebElement> filterLabels;
- @FindBy(xpath="//li[contains(@class,'hover')]//input[not(contains(@class,'country'))]")
- private List<WebElement> filterCheckboxes;
- // Social Profiles List elements.
- // @FindBy(css=".socialProfileList.easy-clearing") tmp decision
- @FindBy(css=".leftArrow")
- private List<WebElement> socialAccountsList;
- @FindBy(css=".socialProfileList.easy-clearing>h3")
- // @FindBy(css=".leftArrow")
- private List<WebElement> socialAccount;
- @FindBy(id="Unassigned_dd")
- // @FindBy(css=".leftArrow")
- private WebElement leftArrow;
- @FindBy(css=".accountName")
- private List<WebElement> accountUserList;
- @FindBy(css=".account_description")
- private WebElement accountDescription;
- @FindBy(css=".user")
- private List<WebElement> ownersList;
- @FindBy(css=".childInfo.easy-clearing>p>a")
- private WebElement companyProfileTabLink;
- @FindBy(xpath =".//span[contains(text(), 'Brands')]/parent::*/*/*/a[contains(text(),'Show Results')]")
- private WebElement showResultButton;
- @FindBy (xpath=".//span[@class='withoutDisplayName']")
- private List<WebElement> listOfNames;
- // @FindBy(xpath="//a[@class='button' and contains(text(), 'Add Social Accounts')]") (*by Dima R)
- @FindBy(css=".button[onclick*='add']")
- private WebElement addSocialAccountsButton;
- // @FindBy(xpath="//a[@class='button' and " +
- // "contains(text(), 'Invite Your Coworkers')]") (*by Dima R)
- @FindBy(css=".button[onclick*='invite']") //link=Invite Your Coworkers
- private WebElement inviteYourCoworkersButton;
- @FindBy(css="input[id='nameSearch']")
- private WebElement searchField;
- @FindBy(xpath="//input[@value='Search']")
- private WebElement searchButton;
- @FindBy(css="div[id='delete']")
- private WebElement closeButton;
- @FindBy(css="#pivotBy")
- private WebElement platformsListFromDropdownMenu;
- @FindBy(css="#pivotBy>option")
- private List<WebElement> pivotFiltersList;
- // @FindBy(css="#col_name>span")
- @FindBy(css="#col_name")
- private List <WebElement> accountNameColumnSpan;
- @FindBy(css="#col_owner")
- private WebElement userColumnSpan;
- @FindBy(css="#col_audience")
- private WebElement audienceColumnSpan;
- @FindBy(xpath="//th[@id='col_signal']")
- private WebElement conversationStrengthColumnSpan;
- @FindBy(xpath="//dd[@id='Twitter_dd']/table/thead/tr/th[@id='col_signal']")
- private WebElement conversationStrengthColumnTwitter;
- @FindBy(css="#col_percentComplete")
- private WebElement percentCompleteColumnSpan;
- //expanded social account elements
- @FindBy(xpath="//a[contains(.,'http')]")
- private WebElement socialAccountLink;
- @FindBy(css=".editAssign>a")
- private WebElement editAccountLink;
- @FindBy(css=".editAssign>a")
- private List <WebElement> listEditAccountLinks;
- @FindBy(css=".profilemessage>a")
- private WebElement messageThisUserLink;
- @FindBy(css=".delete>a")
- private WebElement deleteThisAccountLink;
- @FindBy(linkText="Settings")
- private WebElement settingsButton;
- @FindBy(xpath="//div[@class='settingsMenu']")
- private WebElement settingsMenu;
- @FindBy(css="#Facebook_dd .preview")
- private WebElement topQuestionMarkImg;
- @FindBy(css="#benchmarkingBar")
- private List<WebElement> benchmarkingBarsList;
- @FindBy(css=".industryAverage")
- private List<WebElement> industryAverageList;
- @FindBy(id="trborder")
- private WebElement redBorder;
- @FindBy(xpath="//img[@alt='LinkedIn']")
- private WebElement linkedinImg;
- @FindBy(xpath="//span[contains(text(), 'Account')]")
- private WebElement accountFilerLink;
- @FindBy(xpath="//span[contains(text(), 'Demographics')]")
- private WebElement demographicsFilerLink;
- @FindBy(xpath="//li[text()='Company Associations']")
- private WebElement companyAssosiationsTab;
- @FindBy(xpath="//dd[@class='advocate-associations-title easy-clearing']/span[text()='Regions']/following-sibling::*")
- private WebElement regionName;
- @FindBy(xpath="//dd[@class='advocate-associations-title easy-clearing']/span[text()='Subsidiaries']/following-sibling::*")
- private WebElement subsidiaryName;
- /**
- * Initialize CompanyPortfolioPage.
- *
- * @param driver Driver for Selenium2.
- * @throws InterruptedException
- */
- public CompanyPortfolioPage(WebDriver driver){
- super(driver);
- ElementLocatorFactory finder = new
- AjaxElementLocatorFactory(driver, DRIVER_WAIT);
- PageFactory.initElements(finder, this);
- this.driver = driver;
- common.waitForAjax();
- common.waitForElement(".name");
- try{
- common.waitForElementHide(".//*[@id='curtain_loading']");
- }
- catch(Exception e){
- }
- }
- /**
- * gets Group:by value.
- *
- * @return value.
- */
- public String getGroupByValue(){
- String value = platformsListFromDropdownMenu.getAttribute("value");
- System.out.println(value);
- return value;
- }
- /**
- * Fills needed search term.
- *
- * @param searchTerm Search account term.
- */
- public void fillAndSearchSearchTerm(String searchTerm){
- logger.debug("Fill data for search with following value: <br>" +
- "Search account term - " + searchTerm);
- searchField.clear();
- searchField.sendKeys(searchTerm);
- }
- /**
- * Search accounts by specific term.
- *
- * @param searchTerm Needed search term.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage searchAccount(String searchTerm){
- fillAndSearchSearchTerm(searchTerm);
- searchButton.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Cancel search filter.
- *
- * @param searchTerm Needed search term.
- *
- * @return CompanyPortfolioPage.
- *
- * @throws InterruptedException.
- */
- public CompanyPortfolioPage cancelSearchFilter(String searchTerm) throws InterruptedException{
- fillAndSearchSearchTerm(searchTerm);
- this.clickSearchButton();
- this.clickCloseButton();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks Search button
- *
- * @return CompanyPortfolioPage object
- */
- public CompanyPortfolioPage clickSearchButton(){
- logger.debug("Click [Search] button ");
- searchButton.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks Close button
- *
- * @return CompanyPortfolioPage object
- */
- public CompanyPortfolioPage clickCloseButton(){
- logger.debug("Click [Close] button ");
- closeButton.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Selects random platform from the "Group by:" drop-down menu.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickRandomPlatformFormDropdownMenu(){
- logger.debug("Click random filter in the drop down menu ");
- WebElement randomFilter;
- platformsListFromDropdownMenu.click();
- randomFilter = common.randomElementFromTheList(pivotFiltersList);
- randomFilter.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Selects needed platform from the "Pivot by:" drop-down menu.
- *
- * @param Needed platform
- *
- * @return CompanyPortfolioPage object.
- * @throws InterruptedException.
- */
- public CompanyPortfolioPage clickPlatformFormDropdownMenu(String platform){
- logger.debug("Select needed drop down menu item with following value: <br>" +
- "Needed platform - " + platform);
- common.select(platformsListFromDropdownMenu, platform);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Finds and clicks needed social network.
- *
- * @param socialNetworkName.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage findAndCheckNeededSocialNetwork(String socialNetworkName ){
- WebElement socialNetworkHeader;
- String socialNetwork;
- socialNetwork = "//dd[@id='" + socialNetworkName + "_dd']/h3";
- socialNetworkHeader = accountLoads.findElement(By.xpath(socialNetwork));
- if(accountlist.size() == 0){
- socialNetworkHeader.click();
- }
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Finds and clicks needed social profile.
- *
- * @param socialProfileName.
- *
- * @return CompanyPortfolioPage.
- */
- public CompanyPortfolioPage findAndCheckNeededSocialProfile(String socialProfileName ){
- WebElement socialProfileHeader;
- socialProfileHeader = common.getHeaderElement(socialProfileName);
- socialProfileHeader.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Finds needed symbol in socialprofileName.
- *
- * @param socialProfileName.
- *
- * @param character
- *
- * @return true or false.
- */
- public boolean findAndCheckSymbol(String socialProfileName, String character ){
- WebElement socialProfileHeader;
- String headerTextChar;
- socialProfileHeader = socialProfileForm.findElement(By.cssSelector(cssTwitterAccountName));
- String headertext = socialProfileHeader.getText().toString();
- headerTextChar = headertext.substring(1, 2);
- if(!headerTextChar.equals(character))
- {
- return false;
- }
- else
- return true;
- }
- /**
- * Checks if the account is found. *
- *
- * @return true or false.
- */
- public boolean findAccount(){
- if(accountUserList.isEmpty()){
- return false;
- }
- else
- return true;
- }
- /**
- * Clicks on the needed social network and then clicks [Show more accounts] links
- *
- * @param socialProfileName Social profile name.
- *
- * @return CompanyPortfolioPage object.
- *
- */
- public CompanyPortfolioPage clickShowMoreAccountsLink(String socialProfolioName){
- logger.debug("Click [Show More Accounts] link with following social network: <br>" +
- "social network - " + socialProfolioName);
- WebElement showMore;
- findAndCheckNeededSocialNetwork(socialProfolioName);
- showMore = socialProfileForm.findElement(By.xpath(".//*[@id='" + socialProfolioName + "_more']/td"));
- showMore.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on the needed social network and then clicks [Show more accounts] links until all are shown
- *
- * @param socialProfileName Social profile name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickShowAllAccounts(String socialProfolioName){
- logger.debug("Click Show All Accounts with following social network: <br>" +
- "social network - " + socialProfolioName);
- WebElement showMore;
- this.findAndCheckNeededSocialNetwork(socialProfolioName);
- showMore = socialProfileForm.findElement(By.xpath(".//*[@id='"+socialProfolioName+"_more']/td"));
- if(showMore.isDisplayed()){
- while(showMore.isDisplayed()){
- this.clickWithPageReturn(showMore);
- }
- }
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks [Show More] for network.
- *
- * @param socialProfolioName
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickShowMoreForNetwork(String socialProfolioName){
- logger.debug("Click [Show More] for network with following value: <br>" +
- "social network - " + socialProfolioName);
- try{
- WebElement showMore = socialProfileForm.findElement(By.xpath(".//*[@id='" + socialProfolioName + "_more']/td"));
- this.clickWithPageReturn(showMore);
- }
- catch(Exception e){
- }
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks Show More Link for speciefied
- * social network while it displayed.
- *
- * @param socialProfileName name of social network.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickShowMoreWhileDisplayed(String socialProfileName){
- logger.debug("Click [Show More] link for specified social profile <br>with following value: <br>" +
- "social progile name - " + socialProfileName);
- if(accountlist.size() == 0){
- this.findAndCheckNeededSocialNetwork(socialProfileName);
- }
- try{
- WebElement showMore = socialProfileForm.findElement(By.xpath(".//*[@id='" + socialProfileName + "_more']/td"));
- do{
- this.clickWithPageReturn(showMore);
- }
- while(common.isElementDisplayed(showMore));
- }
- catch(Exception e){
- }
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks Show all accounts.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickShowAllAccounts() {
- logger.debug("Click show all accounts");
- for(WebElement socialPlatform : socialAccountsList){
- String socialPLatformName = socialPlatform.getText().replaceAll(" ","");
- String correctName = socialPLatformName.substring(0,socialPLatformName.indexOf("("));
- this.clickShowAllAccounts(correctName);
- }
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Compares number of accounts in list with number of accounts written in SocialNetworkHeader
- *
- * @param socialProfileName Social profile name.
- *
- * @return CompanyPortfolioPage object.
- *
- */
- public boolean findAndCheckDigits(String SocialNetworkName) {
- WebElement listofaccount1;
- String socialprofileName = ".//dd[@id='" + SocialNetworkName + "_dd']";
- listofaccount1 = socialProfileForm.findElement(By.xpath(socialprofileName));
- String headertext = listofaccount1.getText().toString();
- int listLength = listofaccount.size();
- int accountsCount = Integer.parseInt(headertext.substring(
- headertext.indexOf("(") + 1, headertext.indexOf(")")));
- if (listLength != accountsCount) {
- return false;
- } else
- return true;
- }
- /**
- * Clicks on the needed social network and then sorts data by
- * clicking on the [Account Name] column head name.
- *
- * @param socialProfileName Social profile name.
- *
- * @return CompanyPortfolioPage object.
- *
- * @throws InterruptedException.
- */
- public CompanyPortfolioPage clickAccountNameColumnSpan(String socialPortfolioName) throws InterruptedException{
- logger.debug("Click name column span with next value: <br>" +
- "social network - " + socialPortfolioName);
- WebElement accNameColumnSpan;
- findAndCheckNeededSocialNetwork(socialPortfolioName);
- accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName +"_table']/*/*/th[@id='col_name']/span"));
- accNameColumnSpan.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on the needed social network and then sorts data
- * by clicking on the [User/Owner] column head name.
- *
- * @param socialProfileName Social profile name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickUserColumnSpan(String socialPortfolioName){
- logger.debug("Click on the [User/Owner] column head name with following value: <br>" +
- "social network - " + socialPortfolioName);
- WebElement accNameColumnSpan;
- findAndCheckNeededSocialNetwork(socialPortfolioName);
- accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName + "_table']/*/*/th[@id='col_owner']"));
- accNameColumnSpan.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on the needed social network and then sorts data
- * by clicking on the [User/Owner] column head name.
- *
- * @param socialProfileName Social profile name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickUserColumnSpanWithoutSocialNetworkExpand(String socialPortfolioName){
- logger.debug("Click on the [User/Owner] column head name without network expand " +
- "with next value: " +
- "social network - " + socialPortfolioName + "");
- WebElement accNameColumnSpan;
- accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName + "_table']/*/*/th[@id='col_owner']"));
- accNameColumnSpan.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on the needed social network and then sorts data
- * by clicking on the [Audience] column head name.
- *
- * @param socialProfileName Social profile name.
- *
- * @return CompanyPortfolioPage object.
- *
- * @throws InterruptedException.
- */
- public CompanyPortfolioPage clickAudienceColumnSpan(String socialPortfolioName) throws InterruptedException{
- logger.debug("Click [Audience] column head name <br>" +
- "with following value: <br>" +
- "social network - " + socialPortfolioName);
- WebElement accNameColumnSpan;
- findAndCheckNeededSocialNetwork(socialPortfolioName);
- accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName + "_table']/*/*/th[@id='col_audience']/span"));
- accNameColumnSpan.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on the needed social network and then sorts data
- * by clicking on the [Conversation Strength] column head name.
- *
- * @param socialProfileName Social profile name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickConversationStrnghtColumnSpan(String socialPortfolioName){
- logger.debug("Click [Conversation Strength] column head name <br>" +
- "with following value: <br>" +
- "social network - " + socialPortfolioName);
- WebElement accNameColumnSpan;
- findAndCheckNeededSocialNetwork(socialPortfolioName);
- accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName + "_table']/*/*/th[@id='col_signal']"));
- accNameColumnSpan.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on the needed social network and then sorts data
- * by clicking on the [Percent Complete] column head name.
- *
- * @param socialProfileName Social profile name.
- *
- * @return CompanyPortfolioPage object.
- *
- * @throws InterruptedException.
- */
- public CompanyPortfolioPage clickPercentCompleteColumnSpan(String socialPortfolioName) throws InterruptedException{
- logger.debug("Click [Percent Complete] column head name <br>" +
- "with following value: <br>" +
- "social network - " + socialPortfolioName);
- WebElement accNameColumnSpan;
- findAndCheckNeededSocialNetwork(socialPortfolioName);
- accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+socialPortfolioName+"_table']/*/*/th[@id='col_percentComplete']/span"));
- accNameColumnSpan.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Gets percentage of account
- *
- * @param accountName
- *
- * @return percentage
- */
- public int getPercentComplete(String accountName){
- WebElement account = socialProfileForm.findElement(By.xpath(".//span[contains(.,'" + accountName + "')]"));
- // WebElement account = socialProfileForm.findElement(By.xpath("//span[@class='withoutDisplayName'][contains(.,'" + accountName + "')]"));
- WebElement percent = account.findElement(By.xpath(xpathPercentComplete));
- //String text = percent.getAttribute("textContent");
- String text = percent.getText();
- String percentText = text.substring(0, text.indexOf("%"));
- int nPercent = Integer.parseInt(percentText);
- return nPercent;
- }
- /**
- * Gets percentage of account in text format
- *
- * @param accountName Name of account
- *
- * @return Text with percentage
- */
- public String getTextPercentComplete(String accountName){
- WebElement percent = socialProfileForm.findElement(By.xpath(".//span[text()='"+ accountName +"']/../..//p[@class='percentComplete']"));
- String text = percent.getText();
- return text;
- }
- /**
- * Clicks on random social accounts toggle.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage expandRandomSocExpand(){
- logger.debug("Expand random social account ");
- WebElement randSocExpand;
- randSocExpand = common.randomElementFromTheList(socialAccountsList);
- randSocExpand.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Gets list of account names in Social Network.
- *
- * @param socialProfolioName social profile name.
- *
- * @param sortBy sort account by option.
- *
- * @return list of account names list of names.
- */
- public ArrayList<String> getAccountsNames(String socialProfolioName,
- String sortBy) {
- String listOfElementsPath = null;
- if (sortBy.equals("Account Name")) {
- listOfElementsPath = ".//table[@id='" + socialProfolioName
- + "_table']//td[@class='accountName']";
- } else if (sortBy.equals("User")) {
- listOfElementsPath = ".//table[@id='" + socialProfolioName
- + "_table']//td[@class='user']";
- } else if (sortBy.equals("Audience")) {
- listOfElementsPath = ".//table[@id='" + socialProfolioName
- + "_table']//td[@class='Audience']";
- } else if (sortBy.equals("Conversation")) {
- listOfElementsPath = ".//table[@id='" + socialProfolioName
- + "_table']//td[@class='signal']/div";
- }
- List<WebElement> ownersList = socialProfileForm.findElements(By
- .xpath(listOfElementsPath));
- ArrayList<String> collectionSort = new ArrayList<String>();
- for (WebElement element : ownersList) {
- String name = element.getText();
- String lowerCaseName = name.toLowerCase();
- if (lowerCaseName.indexOf("more") != -1) {
- String correctName = lowerCaseName.substring(lowerCaseName
- .indexOf("\n") + 1);
- collectionSort.add(correctName);
- } else
- collectionSort.add(lowerCaseName);
- }
- return collectionSort;
- }
- /**
- * Sorts account list using collection sorting.
- *
- * @param sortingList List to sort.
- *
- * @return sorted list Sorted list.
- */
- public ArrayList<String> sortAccounts(ArrayList<String> sortingList) {
- int numbers = 0;
- for (String name : sortingList) {
- if (name.matches("\\d+")) {
- numbers++;
- }
- }
- Collections.sort(sortingList);
- if (numbers == sortingList.size()) {
- Collections.reverse(sortingList);
- }
- return sortingList;
- }
- /**
- * Compares two accounts lists.
- *
- * @param first list.
- *
- * @param second list.
- *
- * @return true if lists are equal or false if not.
- */
- public boolean isSortingOrderCorrect(ArrayList<String> collection,
- ArrayList<String> site) {
- Iterator<String> collectionSortIterator = collection.iterator();
- Iterator<String> siteSortIterator = site.iterator();
- boolean isEqual = true;
- while (isEqual && siteSortIterator.hasNext()) {
- if (!collectionSortIterator.next().equals(siteSortIterator.next())) {
- isEqual = false;
- }
- }
- return isEqual;
- }
- /**
- * Checks if social network contains zero accounts
- *
- * @return true or false.
- */
- public boolean isContainZeroAccs(){
- boolean isContainNeededElements = true;
- for(WebElement em : emptySocExpand){
- String socName = em.getText();
- if(!socName.contains("(0) You have not added any"))
- isContainNeededElements = false;
- else if(!socName.contains("accounts + add account"))
- isContainNeededElements = false;
- }
- return isContainNeededElements;
- }
- /**
- * Clicks on each social accounts toggle.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage expandsAllSocialToggles(){
- logger.debug("Expand all social toggles ");
- for (WebElement element : socialAccountsList){
- if(element.isDisplayed()){
- this.clickWithPageReturn(element);
- }
- }
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on the Add Social Accounts
- * button on the CompanyPortfolioPage.
- *
- * @return AddSocialAccountsForm object.
- */
- public AddSocialAccountsForm clickOnAddSocialAccountsButton(){
- logger.debug("Click [Add social account] button ");
- addSocialAccountsButton.click();
- return new AddSocialAccountsForm(driver);
- }
- /**
- * Clicks on the Invite Your Coworkers.
- * button on the CompanyPortfolioPage.
- *
- * @return InviteYourCoworkersForm object.
- */
- public InviteYourCoworkersForm clickOnInviteYourCoworkersForm(){
- logger.debug("Click [Invite Coworkers] button ");
- inviteYourCoworkersButton.click();
- return new InviteYourCoworkersForm(driver);
- }
- /**
- * Clicks on the Clear all filters link
- * on the CompanyPortfolioPage.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickOnClearAllFiltersHref(){
- logger.debug("Click [Clear all filters] link ");
- clearAllFiltersHref.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Removes selected Filter by clicking 'x' near it.
- *
- * @param filterName Name of the filter to remove
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage deselectFilter(String filterName){
- WebElement filter = selectedFilters.findElement(By.xpath(".//a[contains(@onclick, '" + filterName + "')]"));
- filter.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Checks that filter labels are sorted alphabetically.
- *
- * @param labels Filter labels.
- *
- * @return true or false.
- */
- public boolean areFilterLabelsSortedAlphabetically(List<WebElement> labels){
- ArrayList<String> filterSort = new ArrayList<String>();
- ArrayList<String> collectionSort = new ArrayList<String>();
- for(WebElement element : labels){
- String name = element.getText().toLowerCase();
- if(!name.equalsIgnoreCase("Select All") && (name.indexOf("assigned") == -1)){
- filterSort.add(name);
- collectionSort.add(name);
- }
- }
- Collections.sort(collectionSort);
- boolean isCorrect = this.isSortingOrderCorrect(collectionSort, filterSort);
- return isCorrect;
- }
- /* ------------------------------------------- Platforms filter------------------------------------- */
- /**
- * Clicks on the Platforms filter.
- *
- * @return PlatformsFilter object.
- */
- public PlatformsFilter clickOnPlatformsFilter(){
- logger.debug("Click Platform filter ");
- try{
- platformsLink.click();
- }catch(Exception e){
- accountFilter = clickAccountFilter();
- accountFilter.clickPlatformTab();
- }
- return new PlatformsFilter(driver);
- }
- /**
- * Clicks "Platforms" filter and then clicks [Cancel] button in the appeared filter form.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickCancelPlatformsFilter(){
- logger.debug("Click [Cancel link on the 'Palrform' filter form");
- platformsLink.click();
- platformsFilter.clickOnCancelLink();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks "Platforms" filter and then clicks [Show Result] without any checked platform.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickShowResultPlatformsFilter(){
- logger.debug("Click [Show Result] button without check checkboxes ");
- platformsLink.click();
- platformsFilter.clickOnShowResultsButtonWithoutCheckMark();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks "Platforms" filter checks
- * needed platform and then clicks [Show Result].
- *
- * @param platformName name of the platform
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage checkPlatformAndShowResult(String platformName){
- platformsFilter = this.clickOnPlatformsFilter();
- platformsFilter.checkPlatforms(platformName);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the random platform.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage showResultBasedOnRandomPlatformFilter(){
- platformsFilter = this.clickOnPlatformsFilter();
- platformsFilter.checkRandomPlatform();
- return new CompanyPortfolioPage(driver);
- }
- /* ------------------------------------------- Brands filter-------------------------------------- */
- /**
- * Clicks on the Brands filter.
- *
- * @return BrandsFilter object.
- */
- public BrandsFilter clickOnBrandsFilter(){
- logger.debug("Click Brands filter ");
- brandFormLink.click();
- return new BrandsFilter(driver);
- }
- /**
- * Clicks [Cancel] link in the "Brand" filter.
- *
- * @return CompanyPortfolioPage filter.
- */
- public CompanyPortfolioPage clickCancelBrandsFilter(){
- logger.debug("Click [Cancel] link on the Brand filter form ");
- brandFormLink.click();
- brandsFilter.clickOnCancelLink();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks [Show result] link in the "Brand" filter.
- *
- * @return EmployeePortfolioPage filter.
- */
- public CompanyPortfolioPage clickOnShowResultBrandsFilter(){
- logger.debug("Click [Show result] link on Brand filter form ");
- brandFormLink.click();
- brandsFilter.clickOnShowResult();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the checked specified brand.
- *
- * @param brandName Brand name.
- *
- * @return EmployeePortfolioPage object.
- */
- public CompanyPortfolioPage showResultsBasedOnSpecifiedBrandFilter(String brandName){
- brandFormLink.click();
- brandsFilter.showResultsBasedOnSpecifiedBrand(brandName);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the random brand.
- *
- * @return EmployeePortfolioPage object.
- */
- public CompanyPortfolioPage showResultBasedOnRandomBrandFilter(){
- brandsFilter = this.clickOnBrandsFilter();
- brandsFilter.showResultBasedOnRandomBrand();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Show result based on the specified competitors brand name.
- *
- * @param competitorsName Competitors name.
- *
- * @return EmployeePortfolioPage object.
- */
- public CompanyPortfolioPage showResultBasedOnSpecifiedCompetitorsBrandFilter(String competitorsName){
- brandFormLink.click();
- brandsFilter.showResultBasedOnSpecifiedCompetitors(competitorsName);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Show result based on the random competitors brand.
- *
- * @return EmployeePortfolioPage object.
- */
- public CompanyPortfolioPage showResultBasedOnRandomCompetitorsBrandFilter(){
- brandsFilter = this.clickOnBrandsFilter();
- brandsFilter.showResultBasedOnRandomCompetitors();
- return new CompanyPortfolioPage(driver);
- }
- /* ------------------------------------------- Owners filter-------------------------------------- */
- /**
- * Clicks [Cancel] button.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickCancelOwnersFilter(){
- logger.debug("Click [Cancel] link on the Owner filter form ");
- ownersFormLink.click();
- ownersFilter.clickOnCancelLink();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks Subsidiaries filter link
- *
- * @return OwnersFilter object.
- */
- public OwnersFilter clickOwnersLink(){
- logger.debug("Click [Owner] link ");
- ownersFormLink.click();
- return new OwnersFilter(driver);
- }
- /**
- * Shows result without checked owner's checkbox.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickOnShowResultButtonOwnersFilter(){
- logger.debug("Click [Show Result] button in the Owner filter form ");
- ownersFormLink.click();
- ownersFilter.clickOnShowResultButton();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the additional "Unassigned owner" filter.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage checkOwnerUnassignedChecBoxOwnersFilter(){
- logger.debug("Check [Unassigned checkbox on the [Owners] filter form ");
- ownersFormLink.click();
- ownersFilter.checkOwnerUnassignedChecBox();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the specified checked owner.
- *
- * @param ownerName Owner Name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage resultBasedOnCheckedOwner(String ownerName){
- ownersFormLink.click();
- ownersFilter.resultBasedOnCheckedOwner(ownerName);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the random checked owner.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage resultBasedOnRandomOwner(){
- ownersFilter = this.clickOwnersLink();
- ownersFilter.resultBasedOnRandomOwner();
- return new CompanyPortfolioPage(driver);
- }
- /* ------------------------------------------- Regions filter-------------------------------------- */
- /**
- * Clicks [Cancel] button.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickCancelButtonRegionFilter(){
- logger.debug("Click [Cancel] ");
- regionsFormLink.click();
- regionsFilter.clickOnCancelLink();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks Region filter's link.
- *
- * @return Regions Filter Form.
- */
- public RegionsFilter clickRegionsFilter(){
- logger.debug("Click Regions filter");
- demographicsFilerLink.click();
- regionsFormLink.click();
- return new RegionsFilter(driver);
- }
- /**
- * Shows result without checked checkbox.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage showResultWithoutRestriction(){
- regionsFormLink.click();
- regionsFilter.clickOnShowResultButton();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the checked region.
- *
- * @param regionName Region name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage resultBasedOnCheckedGroup(String regionName){
- regionsFormLink.click();
- regionsFilter.checkRegionGroup(regionName);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the checked country in the desired region.
- *
- * @param regionName Region name.
- * @param countryName Country name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage resultBasedOnCheckedCountry(String regionName, String countryName){
- regionsFormLink.click();
- regionsFilter.showReultBasedOnNeededCountry(regionName, countryName);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the random country.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage resultBasedOnRandomCountry(){
- regionsFilter = this.clickRegionsFilter();
- regionsFilter.resultBasedOnRandomCountry();
- return new CompanyPortfolioPage(driver);
- }
- /* ------------------------------------------- Subsidiaries filter-------------------------------------- */
- /**
- * Clicks [Cancel] buton.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickCancelButton(){
- logger.debug("Click [Cancel] button ");
- subsidiariesFormLink.click();
- subsidiariesFilter.clickOnCancelLink();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * clicks Subsidiaries filter link.
- *
- * @return SubsidiariesFilter object
- */
- public SubsidiariesFilter clickSubisiriesLink(){
- logger.debug("Click Subsidiary filter ");
- subsidiariesFormLink.click();
- return new SubsidiariesFilter(driver);
- }
- /**
- * Shows result without checked checkbox.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage showResultWithoutCheckedRestriction(){
- subsidiariesFormLink.click();
- subsidiariesFilter.clickOnShowResultButton();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the checked "Subsidiaries Unassigned" checkbox.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage checkSubsidiariesUnassignedCheckbox(){
- logger.debug("Check unassigned checkbox ");
- subsidiariesFilter = clickSubisiriesLink();
- subsidiariesFilter.checkSubsidiariesUnassignedCheckBox();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the checked desired subsidiaries restriction.
- *
- * @param subsidiariesName Subsidiaries name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage resultBasedOnSubsidiariesCheckbox(String subsidiariesName){
- this.clickSubisiriesLink();
- subsidiariesFilter.checkSubsidiariesCheckbox(subsidiariesName);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the random subsidiary.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage resultBasedOnRandomSubsidiary(){
- subsidiariesFilter = this.clickSubisiriesLink();
- subsidiariesFilter.checkSubsidiaries();
- return new CompanyPortfolioPage(driver);
- }
- /* ------------------------------------------- Departments filter-------------------------------------- */
- /**
- * Clicks [Cancel] button.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickCancelButtonDepartmentsFilter(){
- logger.debug("Click [Cancel] link in the [Department] filter form");
- departmentsFormLink.click();
- departmentsFilter.clickOnCancelLink();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result without checked checkbox.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage showResultWithoutAnyRestriction(){
- departmentsFormLink.click();
- departmentsFilter.clickOnShowResultButton();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the checked "Department Unassigned" checkbox.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage resultBasedOnUnassignedCheckbox(){
- departmentsFormLink.click();
- departmentsFilter.checkDepartmentUnassignedCheckBox();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * clicks department filter's link
- *
- * @return Regions Filter Form
- */
- public DepartmentsFilter clickDepartmentsFilter(){
- logger.debug("Click Department filter");
- departmentsFormLink.click();
- return new DepartmentsFilter(driver);
- }
- /**
- * Shows result based on the checked specified department.
- *
- * @param departmentName Department name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage showResultBasedOnSpecifiedDepartment(String departmentName){
- departmentsFormLink.click();
- departmentsFilter.showResultBasedOnCheckedSpecifiedDepartment(departmentName);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Shows result based on the random department.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage resultBasedOnRandomDepartment(){
- departmentsFilter = this.clickDepartmentsFilter();
- departmentsFilter.checkRandomDepartment();
- return new CompanyPortfolioPage(driver);
- }
- /*----------------------------------------------------------------------------------------------------- */
- /**
- * Clicks on the Edit Account link for the
- * specific Social Account.
- *
- * @param accountUserName.
- *
- * @return editSocialAccountsForm object.
- */
- public AddSocialAccountsForm clickOnEditAccountLink(String accountUserName) {
- logger.debug("Click [Edit Account] link with following value: <br>" +
- "accountUserName - social account name ");
- WebElement socialProfileEditAccountLink;
- this.findAndCheckNeededSocialProfile(accountUserName);
- this.mouseOverAccountSettings();
- socialProfileEditAccountLink = socialProfileForm.findElement(By
- .xpath(".//tbody/tr/td/div/h2[contains(.,'" + accountUserName
- + "')]/../..//a[contains(.,'Edit Account Info')]"));
- common.jsClick(socialProfileEditAccountLink);
- return new AddSocialAccountsForm(driver);
- }
- /**
- * Clicks on Settings.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickSettings(){
- logger.debug("Click settings ");
- settingsButton.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on Export Result link.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickExportResultsLink(){
- exportResultsLink.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Exports accounts to xls file.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage exportResults(){
- String filespath = common.getProjectRoot() + "test-data" + "\\files";
- System.out.println(filespath);
- common.deleteFile(filespath + "\\accounts.xls");
- this.clickSettings();
- this.clickExportResultsLink();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on Import Accounts link.
- *
- * @return CompanyPortfolioPage object.
- */
- public ImportSocialAccountsForm clickImportAccountsLink(){
- logger.debug("Click [Import Accounts] link ");
- importAccountsLink.click();
- return new ImportSocialAccountsForm(driver);
- }
- /**
- * Imports accounts from file.
- *
- * @param filePath Absolute path to file with file name.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage importAccounts(String filePath){
- this.clickSettings();
- importSocialAccountsForm = this.clickImportAccountsLink();
- importSocialAccountsForm.importFile(filePath);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Creates file with accounts and imports one
- *
- * @return CompanyPortfolioPage object.
- *
- */
- public CompanyPortfolioPage createFileAndImport(int numOfAccounts, String network) {
- this.clickSettings();
- importSocialAccountsForm = this.clickImportAccountsLink();
- try {
- importSocialAccountsForm.importFileWithRandomAccounts(numOfAccounts, network, "company");
- } catch (IOException e) {
- }
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks on the Edit Account link for the
- * specific Social Account.
- *
- * @param accountUserName.
- *
- * @return editSocialAccountsForm object.
- */
- public AddSocialAccountsForm clickOnEditLinkInAccountDetails(String accountUserName) {
- logger.debug("Click [Edit Account] link in account details for specified user: <br>" +
- "user name - " + accountUserName);
- WebElement socialProfileEditAccountLink;
- socialProfileEditAccountLink = socialProfileForm.findElement(By
- .xpath(".//li[contains(.,'" + accountUserName
- + "')]/../..//a[contains(.,'Edit Account')]"));
- socialProfileEditAccountLink.click();
- return new AddSocialAccountsForm(driver);
- }
- /**
- * Clicks on the Message These Users link for the
- * specific Social Account.
- *
- * @param accountUserName
- *
- * @return emailAccountOwnersForm object.
- */
- public EmailAccountOwnersForm clickOnMessageTheseUsersLink(String accountUserName) {
- logger.debug("Click [Message this user] link");
- WebElement socialProfileEditAccountLink;
- this.findAndCheckNeededSocialProfile(accountUserName);
- socialProfileEditAccountLink = socialProfileForm.findElement(By
- .xpath(".//li[contains(.,'" + accountUserName
- + "')]/../..//a[contains(.,'Message these users')]"));
- socialProfileEditAccountLink.click();
- return new EmailAccountOwnersForm(driver);
- }
- /**
- * Clicks on the Assign Account Owner link for the
- * specific Accounts user name.
- *
- * @param AccountUserName Accounts user name.
- *
- * @return AccountOwnerInformationForm object.
- */
- public AccountOwnerInformationForm clickOnAssignAcctOwnerLink(
- String AccountUserName) {
- logger.debug("Click [Assign account] link ");
- WebElement accountName, assignAccountOwnerLink;
- accountName = common.findElementInList(accountUserList,
- AccountUserName);
- common.mouseOver(accountName);
- assignAccountOwnerLink = accountName.findElement(
- By.xpath(xpathAssignAccountLink));
- assignAccountOwnerLink.click();
- return new AccountOwnerInformationForm(driver);
- }
- /**
- * Clicks on the [+add account] link.
- *
- * @param socialAccount Social Account Name.
- *
- * @return AddSocialAccountsForm object.
- */
- public AddSocialAccountsForm clickOnAddAccountLink(String socialAccountType) {
- logger.debug("Click [Add Account] link");
- // WebElement socialAccountName, addAccountLink;
- // socialAccountName = common.findElementInList(socialAccountsList,
- // socialAccount);
- // common.mouseOver(socialAccountName);
- // addAccountLink = socialAccountName.findElement(
- // By.xpath("//a[contains(text(), '+ add account')]"));
- // addAccountLink.click();
- WebElement addAccountLink;
- String accountType = socialAccountType.toLowerCase();
- addAccountLink = socialProfileForm.findElement(By.xpath("//a[contains(@onclick,'" + accountType + "')]"));
- addAccountLink.click();
- return new AddSocialAccountsForm(driver);
- }
- /**
- * Opens External Social Account Url.
- *
- * @param accountUserName Account User Name
- *
- * @version 2.
- */
- public void openExternalAccountUrl(String accountUserName) {
- WebElement socialProfileExternalUrl;
- socialProfileExternalUrl = socialProfileForm.findElement(By.xpath(xpathExternalAccountUrl));
- socialProfileExternalUrl.click();
- }
- /**
- * checks if all socialNetworkExpands displayed needed count of accounts.
- *
- * @param countValid needed count of accounts.
- *
- * @return true or false.
- */
- public boolean isCountValidInExpands(int countValid) {
- boolean validExpand = true;
- for (WebElement each : listofSocials) {
- this.clickWithPageReturn(each);
- List<WebElement> accounts = each.findElements(By.xpath(".//..//span[contains(@class,'withoutDisplayName')]"));
- int listSize = accounts.size();
- if (listSize > countValid) {
- validExpand = false;
- }
- this.clickWithPageReturn(each);
- }
- return validExpand;
- }
- /**
- * Checks is filter label displayed.
- *
- * @param filterName Filter name.
- *
- * @return true or false.
- */
- public boolean isSelectedFilterLabelDisplayed(String filterName){
- // List <WebElement> listOfSelectedFilters;
- // listOfSelectedFilters = selectedFilters.findElements(By.xpath(xpathListOfSelectedFilters));
- WebElement filter = common.findElementInList(listOfSelectedFilters, filterName);
- boolean isDisplayed = common.isElementDisplayed(filter);
- return isDisplayed;
- }
- /**
- * Checks if cssValue overflow is hidden, if it's hidden then long account
- * names are half hidden.
- *
- *
- * @return true or false.
- */
- public boolean isNotWrapped(){
- boolean isNotWrapp = true;
- for (WebElement em :listOfNames){
- String scrollWidth = em.getCssValue("overflow");
- if(!scrollWidth.equals("hidden")){
- isNotWrapp = false;
- }
- }
- return isNotWrapp;
- }
- /**
- * checks if all account audience contains comma if it more than 999.
- *
- *
- * @return true or false.
- */
- public boolean isContainComma(){
- boolean isWithComma = true;
- for (WebElement em : listofAudience){
- String textAudience = em.getText();
- if(textAudience.length()>3 && !textAudience.contains("Pending")){
- if(!textAudience.contains(",")){
- isWithComma = false;
- return isWithComma;
- }
- }
- }
- return isWithComma;
- }
- /**
- * Checks count of displayed accounts in social network.
- *
- * @param network Social network.
- * @param num Needed number of accounts to display.
- *
- * @return true or false.
- */
- public boolean isAccountsOnPageCountValid(String network, int num){
- WebElement networkIndex = cpForm.findElement(By.id(network + "_index"));
- String index = networkIndex.getText();
- int indexNumber = Integer.parseInt(index);
- if(indexNumber == num && num == accountlist.size()){
- return true;
- }
- else return false;
- }
- /** If social accounts more than 80 in social network headers, then all expands should be closed,
- * if more than 80 then should be collapsed.
- *
- * @return true or false.
- */
- public boolean isSocialNetworksExpandedorNot(){
- int count = 0;
- boolean isExpanded = false;
- for(WebElement each : listofSoc){ //for Each Social network on the page;
- String headertext = each.getText();
- int accountsCount = Integer.parseInt(headertext.substring(
- headertext.indexOf("(") + 1, headertext.indexOf(")"))); //we take number of accounts from each Social network Header;
- count = count+accountsCount;
- }
- if(count < 80){
- isExpanded = true;
- }
- return isExpanded;
- }
- /**
- * Clicks on random account name.
- *
- * @return account name.
- */
- public String clickRandomName(){
- logger.debug("Click random account name ");
- WebElement randomAccount;
- randomAccount = common.randomElementFromTheList(accountUserList);
- this.clickWithPageReturn(randomAccount);
- return randomAccount.getText();
- }
- /**
- * Gets random account name.
- *
- * @return account name.
- */
- public String getRandomName(){
- String[] result;
- String name = common.randomElementFromTheList(accountUserList).getText();
- if (name.contains("@"))
- {
- result = name.split(" ");
- name = result[0];
- }
- return name;
- }
- /**
- * Clicks on random account name with no ajax wait.
- *
- * @return account name.
- */
- public String clickRandomNameNoAjax(){
- logger.debug("Click random account name with no ajax wait ");
- WebElement randomAccount;
- randomAccount = common.randomElementFromTheList(accountUserList);
- randomAccount.click();
- return randomAccount.getText();
- }
- /**
- * Clicks Random account assign link.
- *
- * @return true or false.
- */
- public AccountOwnerInformationForm clickRandomAssignAcct(){
- logger.debug("Click random [assign] link ");
- WebElement randomUser;
- randomUser = listofAssigns.get((int)(Math.random()*100)%listofAssigns.size());
- randomUser.click();
- return new AccountOwnerInformationForm(driver);
- }
- /**
- * Gets account names.
- *
- * @return List of names.
- */
- public ArrayList<String> getAccountNames(){
- ArrayList<String> accountsName = new ArrayList<String>();
- accountsName = common.getText(accountlist);
- return accountsName;
- }
- /**
- * Compares number of accounts in list with number of accounts written in
- * SocialNetworkHeader.
- *
- * @return true of false.
- **/
- public boolean isNumberOfAccountsCorrect() {
- boolean validExpand = true;
- if(common.isElementDisplayed(leftArrow)){
- return validExpand;
- }
- for (WebElement each : socialAccount) {
- if(!common.isElementDisplayed(userColumnSpan)){
- this.clickWithPageReturn(each);
- }
- try{
- WebElement showMore = each.findElement(By.xpath(".//..//td[@colspan]"));
- while(common.isElementDisplayed(showMore)){
- this.clickWithPageReturn(showMore);
- }
- }catch(NoSuchElementException e){}
- List<WebElement> accounts = each.findElements(By.xpath(".//..//span[contains(@class,'withoutDisplayName')]|.//..//i[contains(@class,'display_nameEllipsis')]"));
- int listSize = accounts.size();
- String displayedCount = each.getText();
- int displayedCountNumber = Integer.parseInt(displayedCount.substring(
- displayedCount.lastIndexOf("(") + 1, displayedCount.lastIndexOf(")")));
- if (listSize != displayedCountNumber) {
- validExpand = false;
- }
- each.click();
- }
- return validExpand;
- }
- /**
- * Clicks specified webelement and returns Company Portfolio Page object.
- *
- * @param elementToClick WebElement to click.
- *
- * @return CompanyPortfolioPage.
- */
- public CompanyPortfolioPage clickWithPageReturn(WebElement elementToClick){
- elementToClick.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Checks aligning of the elements (such as account name, user name, percent) in one random row.
- *
- * @return true or false.
- */
- public boolean areElementsVerticallyAlignedInRandomRow(){
- boolean isAligned = true;
- WebElement row = common.randomElementFromTheList(allListPage);
- int rowHeight = row.getSize().getHeight();
- int rowY = row.getLocation().getY();
- int rowBaseline = rowY + rowHeight/2;
- WebElement accountName = row.findElement(By.xpath(".//span[contains(@class,'withoutDisplayName')]|.//i[contains(@class,'display_nameEllipsis')]"));
- int accountHeight = accountName.getSize().getHeight();
- int accountY = accountName.getLocation().getY();
- int accountBaseline = accountY + accountHeight/2;
- if(Math.abs(rowBaseline - accountBaseline)>3){
- isAligned = false;
- }
- WebElement userName = row.findElement(By.xpath(".//td[@class='user']/a|.//div[@class='ellipsis']"));
- int userHeight = userName.getSize().getHeight();
- int userY = userName.getLocation().getY();
- int userBaseline = userY + userHeight/2;
- if(Math.abs(rowBaseline - userBaseline)>3){
- isAligned = false;
- }
- WebElement signal = row.findElement(By.xpath(".//td[@class='signal']/*"));
- int signalHeight = signal.getSize().getHeight();
- int signalY = signal.getLocation().getY();
- int signalBaseline = signalY + signalHeight/2;
- if(Math.abs(rowBaseline - signalBaseline)>3){
- isAligned = false;
- }
- WebElement circle = row.findElement(By.xpath(".//td[@id='complete']/div"));
- int circleHeight = circle.getSize().getHeight();
- int circleY = circle.getLocation().getY();
- int circleBaseline = circleY + circleHeight/2;
- if(Math.abs(rowBaseline - circleBaseline)>3){
- isAligned = false;
- }
- WebElement percentComplete = row.findElement(By.xpath(".//*[@id='complete']/p[1]"));
- int percentHeight = percentComplete.getSize().getHeight();
- int percentY = percentComplete.getLocation().getY();
- int percentBaseline = percentY + percentHeight/2;
- if(Math.abs(rowBaseline - percentBaseline)>3){
- isAligned = false;
- }
- int moreBaseline = rowBaseline;
- int moreInfoBaseline = rowBaseline;
- int pendingBaseline = rowBaseline;
- try{
- WebElement more = row.findElement(By.xpath(".//div[contains(text(), 'more')]"));
- int moreHeight = more.getSize().getHeight();
- int moreY = more.getLocation().getY();
- moreBaseline = moreY + moreHeight/2;
- if(Math.abs(rowBaseline - moreBaseline)>1){
- isAligned = false;
- }
- WebElement moreInfo = row.findElement(By.xpath(".//td[@class='moreInfo']/span"));
- int moreInfoHeight = moreInfo.getSize().getHeight();
- int moreInfoY = moreInfo.getLocation().getY();
- moreInfoBaseline = moreInfoY + moreInfoHeight/2;
- if(Math.abs(rowBaseline - moreInfoBaseline)>1){
- isAligned = false;
- }
- WebElement pending = row.findElement(By.xpath(".//td[@class='Audience']/*"));
- int pendingHeight = pending.getSize().getHeight();
- int pendingY = pending.getLocation().getY();
- pendingBaseline = pendingY + pendingHeight/2;
- if(Math.abs(rowBaseline - pendingBaseline)>1){
- isAligned = false;
- }
- }catch(NoSuchElementException e){};
- return isAligned;
- }
- /**
- * Mouses over random 'Percent Complete' cell.
- *
- * @return appeared link 'Edit Account'.
- */
- public WebElement mouseOverRandomPercentComplete(){
- boolean isDisplayed = false;
- int counter = 0;
- WebElement editLink = null;
- do{
- try{
- WebElement randomRow = common.randomElementFromTheList(allListPage);
- String jQuery = "jQuery('";
- String mouseOver = "').mouseover();";
- JavascriptExecutor js = (JavascriptExecutor) driver;
- js.executeScript(jQuery + cssAccountEditLink + mouseOver);
- //common.mouseOverJQuery(cssAccountEditLink);
- editLink = randomRow.findElement(By.xpath(".//td/p/a"));
- isDisplayed = editLink.isDisplayed();
- counter ++;
- if(isDisplayed){
- editLink.click();
- }
- }
- catch(Exception e){
- }
- }
- while(!isDisplayed && counter < 50);
- return editLink;
- }
- /**
- * Checks if the Company Portfolio Page is Displayed
- *
- * @return isDisplayed or not.
- */
- public boolean isCompanyPortfolioPageDisplayed(){
- boolean isDisplayed;
- isDisplayed = common.isElementDisplayed(searchField);
- return isDisplayed;
- }
- /**
- * Checks if the accounts exists on the page.
- *
- * @param name name of account .
- *
- * @return true or false.
- *
- */
- public boolean isAccountExists(String name){
- return common.isAccountExists(name);
- }
- /**
- * Checks if the audience list is sorted by audience.
- *
- * @return true or false.
- */
- public boolean isSortedByAudience(){
- boolean isSorted = common.isSortedByAudience(audienceList);
- return isSorted;
- }
- /**
- * Checks if the accounts are sorted alphabetically .
- *
- * @return true or false.
- */
- public boolean isSortedByAlphabet(){
- boolean isSorted = common.isSortedByAlphabets(accountlist);
- return isSorted;
- }
- /**
- * Clicks on the audience column.
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickAudienceColumn(){
- logger.debug("Click Audience column ");
- common.clickVisibleElementsinList(columnAudience);
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Checks if the CoWorkers button is displayed or not.
- *
- * @return true or false.
- */
- public boolean isCoWorkersButtonAndTextDisplayed(){
- boolean isDisplayed, textAndButtonDisplayed = false;
- String workersText = inviteYourCoworkersButton.getText();
- isDisplayed = common.isElementDisplayed(inviteYourCoworkersButton);
- if(workersText.equals("Invite Your Coworkers") && isDisplayed ){
- textAndButtonDisplayed = true;
- }
- return textAndButtonDisplayed;
- }
- /**
- * Checks if the Owner span is Correct.
- *
- * @return true or false.
- */
- public boolean isOwnerSpanIsCorrect(){
- String text;
- boolean isCorrect = false;
- boolean isDisplayed;
- isDisplayed = common.isElementDisplayed(ownersSpan);
- text = ownersSpan.getText();
- if(text.equals("Owners") && isDisplayed){
- isCorrect = true;
- }
- return isCorrect;
- }
- /**
- * Checks if the Import/Export window is displayed.
- *
- * @return true or false.
- */
- public boolean isImportExportDisplayed(){
- boolean isDisplayed;
- isDisplayed = common.isElementDisplayed(importExportWindow);
- return isDisplayed;
- }
- /**
- * Clicks on the drop down menu
- *
- * @return CompanyPortfolioPage object.
- */
- public CompanyPortfolioPage clickDropDownMenu(){
- logger.debug("Click Drop down menu ");
- platformsListFromDropdownMenu.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Checks if the drop down list contains 'owners' option
- *
- * @return true or false.
- */
- public boolean isContainsOwnersInGroupBy(){
- boolean isContains;
- isContains = common.isContain(pivotFiltersList,"Owner");
- return isContains;
- }
- /**
- * Checks if the search filters list contains 'owners' option
- *
- * @return true or false.
- */
- public boolean isContainsOwnersInSearchFilters(){
- boolean isContains;
- isContains = common.isContain(listOfFilters,"Owner");
- return isContains;
- }
- /**
- * Checks if the industry average list is not wrapped.
- *
- * @return true or false.
- */
- public boolean isIndustryAverageListIsNotWrapped(){
- boolean isNotWrapped;
- isNotWrapped = common.isElementInside(industryAverageList);
- return isNotWrapped;
- }
- /**
- * Checks if the conversation column text correct or not.
- *
- * @return true or false.
- */
- public boolean isConversationStrengthColumnTextCorrect(){
- String text;
- boolean isCorrect = false;
- text = conversationStrengthColumnTwitter.getText();
- if(text.contains("Conversation")){
- isCorrect = true;
- }
- return isCorrect;
- }
- /**
- * Sets 'display:"block;"' parameter for Account Settings
- *
- */
- public void mouseOverAccountSettings(){
- WebElement icon;
- icon = socialProfileForm.findElement(By.cssSelector(cssSettingsIcon));
- common.mouseOver(icon);
- int counter = 0;
- do{
- common.displayBlock(xpathHoverHelperDiv);
- common.displayBlock(xpathAccountSettings);
- counter ++;
- }
- while(!common.isElementDisplayed(edit) && counter < 6);
- }
- /**
- * Mouse over Import Export
- *
- */
- public void mouseOverImportExport(){
- common.mouseOverJQuery((".profileSettings"));
- }
- /**
- * Clicks on edit account link.
- *
- * @return AddSocialAccountsForm page object.
- */
- public AddSocialAccountsForm clickEditLink(){
- logger.debug("Click [Edit] link ");
- this.mouseOverAccountSettings();
- editAccountLink.click();
- return new AddSocialAccountsForm(driver);
- }
- /**
- * Mouse over settings image using selenium mouse over.
- *
- */
- public void seleniumMouseOverSettingsImage() {
- common.mouseOver(importExportLink);
- }
- /**
- * Checks if the red border is displayed or not.
- *
- * @return true or false.
- */
- public boolean isRedBorderDisplayed(){
- boolean isDisplayed;
- isDisplayed = common.isElementDisplayed(redBorder);
- return isDisplayed;
- }
- /**
- * Checks if the only one platform name is displayed or not.
- *
- * @param platformName platform name to check.
- *
- * @return true or false.
- */
- public boolean isOnlyOnePlatfromDisplayed(String platformName){
- boolean isOnlyOne;
- isOnlyOne = common.isOnlyOneElementFromListDisplayed(listofSoc, platformName);
- return isOnlyOne;
- }
- /**
- * Checks if the region is correct.
- *
- * @param region regions to check.
- *
- * @return true or false.
- */
- public boolean isRegionCorrect(String region){
- boolean isCorrect;
- this.clickAssocitionsLinks();
- isCorrect = common.isContain(regions, region);
- return isCorrect;
- }
- /**
- * Checks if the LinkedIn image is displayed or not.
- *
- * @return true or false.
- */
- public boolean isLinkedinImageDisplayed(){
- boolean isDisplayed;
- isDisplayed = common.isElementDisplayed(linkedinImg);
- return isDisplayed;
- }
- /**
- * Checks if the triangle image near accounts name is on the same height as accounts name.
- *
- * @return true or false.
- */
- public boolean isTriangleOfAccountIsNotWrapped(){
- boolean isNotWrapped;
- isNotWrapped = common.isElementsOnTheSameRow(allListPage, cssSpanWithArrow, cssAccountNameSpan);
- return isNotWrapped;
- }
- /**
- * checks if the accounts name is on the same height as the social network icon.
- *
- * @return true or false.
- */
- public boolean isAccountNameisRelativeToSocialNetworkIcon(){
- boolean isRelative;
- // isRelative = common.isElementAligningRelativeTo(this.allListPage,".//img",
- // ".//span[@class='withoutDisplayName withoutDisplayWidth']");
- isRelative = common.isElementAligningRelativeTo(allListPage,".//img",
- "..//span[@class='withoutDisplayName withoutDisplayWidth']" +
- "|//i[@class='ellipsis display_nameEllipsis']");
- return isRelative;
- }
- /**
- * Expands needed number of accounts.
- *
- * @param numberOfAccounts number of accounts to open.
- */
- public void expandAccounts(int numberOfAccounts){
- common.expandsAccounts(accountUserList, numberOfAccounts);
- }
- /**
- * Checks if the filter labels are selected alphabetically or not.
- *
- * @return true or false.
- */
- public boolean areFiltersSortedByAlphabeticaly(){
- boolean areSorted;
- areSorted = this.areFilterLabelsSortedAlphabetically(filterLabels);
- return areSorted;
- }
- /**
- * Checks if the list of selected filers is displayed or not.
- *
- * @return true or false.
- */
- public boolean isListOfSelectedFiltersDisplayed(String filtername){
- List <WebElement> listOfFilters = null;
- boolean isDisplayed;
- try{
- listOfFilters = selectedFilters.findElements(By.xpath(xpathListOfSelectedFilters));
- }
- catch (Exception e){
- listOfFilters = listOfSelectedFilters;
- }
- isDisplayed = common.isContain(listOfFilters, filtername);
- return isDisplayed;
- }
- /**
- * Checks if the social accounts is displayed or not.
- *
- * @return true or false.
- */
- public boolean isSocialAccountLisDisplayed(){
- boolean isDisplayed;
- isDisplayed = common.areAllElemementsFromListDisplayed(socialAccountsList);
- return isDisplayed;
- }
- /**
- * Checks if the only one social network is displayed or not.
- *
- * @param network network that should be displayed.
- *
- * @return true or false.
- */
- public boolean isOnlyOneSocialNetworkDisplayed(String network){
- boolean isDisplayed;
- isDisplayed = common.isOnlyOneElementFromListDisplayed(listofSoc, network);
- return isDisplayed;
- }
- /**
- * Clicks 'clear all filters' link.
- *
- * @return CompanyPortfolioPage page object.
- */
- public CompanyPortfolioPage clickClearAllFilters(){
- logger.debug("Click [Clear all filters] link ");
- clearAllFiltersHref.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Clicks 'clear all filters' link.
- *
- */
- public void clickClearAllFiltersNoAjax(){
- clearAllFiltersHref.click();
- }
- /**
- * Checks if the filter checkboxes checked.
- *
- * @return true or false.
- */
- public boolean isFilterCheckboxesChecked(){
- boolean isChecked;
- isChecked = common.isAllCheckboxesChecked(filterCheckboxes);
- return isChecked;
- }
- /**
- * Checks if the filter checkboxes unchecked.
- *
- * @return true or false.
- */
- public boolean isFilterCheckboxesUnchecked(){
- boolean isUnchecked;
- isUnchecked = common.isAllCheckboxesUnchecked(filterCheckboxes);
- return isUnchecked;
- }
- /**
- * Checks if the selected filter is displayed.
- *
- * @return true or false.
- */
- public boolean selectedFiltersIsDisplayed(){
- boolean isDisplayed;
- isDisplayed = common.isElementDisplayed(selectedFiltersTitle);
- return isDisplayed;
- }
- /**
- * Checks if the Edit link is displayed or not.
- *
- * @return true or false.
- */
- public boolean isEditLinkDisplayed(){
- boolean isDisplayed;
- isDisplayed = common.isElementDisplayed(editAccountLink);
- return isDisplayed;
- }
- public void waitUntilLoadingComplete(){
- common.waitForElementHide(".//*[@id='filters']/div/p/span");
- }
- /**
- * Check if the ajax is used or not
- *
- * @param ajax. number of ajax requests to check.
- *
- * @return true or false.
- */
- public boolean isAjaxIsUsed(int ajax){
- boolean isAjaxUsed;
- isAjaxUsed = common.isAjaxUsedOrNot(ajax);
- return isAjaxUsed;
- }
- /**
- * Maximizes window.
- */
- public Dimension getWindowSize(){
- Dimension windowSize = common.getWindowSize();
- return windowSize;
- }
- /**
- * Switch to Facebook page.
- *
- */
- public void switchToFacebook(){
- common.switchToWindowUsingTitle("Facebook");
- }
- /**
- * Checks if the first windows smaller then seconds .
- *
- * @param firstDimension first window dimension.
- *
- * @param secondDimension second window dimension.
- *
- * @return true or false.
- */
- public boolean isFirstElementSmaller(Dimension firstDimension , Dimension secondDimension){
- boolean isSmaller;
- isSmaller = common.isFirstElementSmaller(firstDimension, secondDimension);
- return isSmaller;
- }
- /**
- * Checks if the Account is first in the list.
- *
- * @param accountName account name.
- *
- * @return true or false.
- */
- public boolean isAccountIsFirstInlist(String accountName){
- boolean isFirst;
- isFirst = common.isFirstInList("//span[contains(@class,'withoutDisplayName')]", accountName);
- return isFirst;
- }
- /**
- * Refreshs page.
- *
- * @return CompanyPortfolioPage page object.
- */
- public CompanyPortfolioPage refreshPage(){
- driver.navigate().refresh();
- return new CompanyPortfolioPage(driver);
- }
- public void waitForLoad(){
- common.waitForAjax("2");
- common.waitForAjax("0");
- common.waitForElement(".name");
- }
- /**
- * Takes list of filters.
- *
- * @param xpath xpath of filters.
- *
- * @return listOfFilters.
- */
- public List<String> listOfSelectedFilters(String xpath){
- List<String> listOfFilters = new ArrayList<String>();
- listOfFilters = common.listOfSelectedFilters(xpath);
- return listOfFilters;
- }
- /**
- * Checks if the accounts are filtered or not.
- *
- * @param listofFilters list of filters.
- *
- * @param xpath xpath of account details.
- *
- * @return true or false.
- */
- public boolean isAccountsAreFiltered(List<String> listofFilters, String xpath){
- boolean isFiltered;
- isFiltered = common.isAccountsAreFiltered(listofFilters, xpath);
- return isFiltered;
- }
- /**
- * Gets accounts from xls file.
- *
- * @param path file path of xls file.
- *
- * @return true or false.
- */
- public ArrayList<String> getAccountsFromXlsFile(String path){
- ArrayList<String> accounts = new ArrayList<String>();
- accounts = common.getAccountsFromXlsFile(path);
- return accounts;
- }
- /**
- * Gets accounts from xls file.
- *
- * @param path file path of xls file.
- *
- * @param sheet number of sheet in xls file.
- *
- * @return true or false.
- */
- public ArrayList<String> getAccountsFromXlsFile(String path, int sheet){
- ArrayList<String> accounts = new ArrayList<String>();
- accounts = common.getAccountsFromXlsFile(path, sheet);
- return accounts;
- }
- /**
- * Checks if the sheet in xls file present.
- *
- * @param filepath file path of xls file.
- *
- * @param sheetNumber. number of sheet in xls file.
- *
- * @return true or false.
- */
- public boolean isSheetPresent(String filepath, int sheetNumber){
- boolean isPresent;
- isPresent = common.isSheetPresent(filepath, sheetNumber);
- return isPresent;
- }
- /**
- * Gets accounts from cvs file.
- *
- * @param path path of file.
- *
- * @return true or false.
- */
- public ArrayList<String> getAccountsNameFromCvsFile(String path){
- ArrayList<String> accounts = new ArrayList<String>();
- try {
- accounts = common.getAccountsNameFromCvsFile(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return accounts;
- }
- /**
- * Deletes accounts.xls file
- */
- public void deleteAccountsXls(){
- common.deleteFile("C:\\accounts.xls");
- }
- /**
- * Clicks [Associations] links
- */
- public void clickAssocitionsLinks(){
- List <WebElement> listofLinks;
- listofLinks = socialProfileForm.findElements(By.xpath(xpathAssociationsLink));
- for(WebElement link : listofLinks){
- this.clickWithPageReturn(link);
- }
- }
- /**
- * Clicks on edit link.
- *
- * @return AddSocialAccountsForm object .
- */
- public AddSocialAccountsForm clickOnSpecifiedEditAccountLink(){
- logger.debug("Click [Edit Account] link ");
- WebElement editLink;
- editLink = this.mouseOverRandomPercentComplete();
- editLink.click();
- return new AddSocialAccountsForm(driver);
- }
- /**
- * Checks if the accounts are sorted by conversation correctly or not.
- *
- * @param sortedBySiteList
- *
- * @return true or false.
- */
- public boolean isSortedByConversation(ArrayList<String> sortedBySiteList){
- boolean isEqual = true;
- int nextConversation, previousConversation;
- int listSize = sortedBySiteList.size();
- for(int a = 0, b = 1; b < listSize; a++, b++){
- previousConversation = Integer.parseInt(sortedBySiteList.get(a));
- nextConversation = Integer.parseInt(sortedBySiteList.get(b));
- if(previousConversation < nextConversation){
- return false;
- }
- }
- return isEqual;
- }
- public void cleanNeededNetworkSocialAccounts(String network, String username, String password){
- List <WebElement> socAccounts;
- String accountName, headerText;
- ArrayList<String> accounts = new ArrayList<String>();
- headerText = "of";
- WebElement socialHeader;
- do{
- socialHeader = socialProfileForm.findElement(By.xpath(".//*[@id='"+ network +"_dd']/h3"));
- this.findAndCheckNeededSocialNetwork(network);
- socAccounts = socialProfileForm.findElements(By.xpath(".//span[@class='withoutDisplayName']"));
- for(WebElement account : socAccounts){
- accountName = account.getText();
- if(accountName.contains("mister") || accountName.contains("accountname")){
- accounts.add(accountName);
- }
- }
- headerText = socialHeader.getText();
- this.deleteAccountsByNetworkAndName(username, password, accounts, network);
- accounts.clear();
- this.refreshPage();
- }
- while(headerText.contains("of"));
- }
- public CompanyPortfolioPage deleteAccountsByNetworkAndName(String username , String password, ArrayList<String> accounts, String network){
- for(String accountName : accounts){
- coreApi.removeSocialAccount(username, password, network, accountName);
- }
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Checks if the platforms displayed or not.
- *
- * @param platformNameList
- *
- * @return true or false
- */
- public boolean isPlatformsDisplayed(ArrayList<String> platformNameList){
- WebElement platform;
- String path;
- for(String platformName : platformNameList){
- path = "//dl//dd/h3[contains(.,'" + platformName + "')]";
- try{
- platform = socialProfileForm.findElement(By.xpath(path));
- if(!common.isElementDisplayed(platform)){
- return false;
- }
- }catch(Exception e){
- return false;
- }
- }
- return true;
- }
- /**
- * Gets group labels.
- *
- * @return list of labels
- */
- public List<WebElement> getGroupLabelList(){
- return socialAccount;
- }
- /**
- * Checks two lists to equality.
- *
- * @param brandsBefore
- * @param brandsAfter
- *
- * @return true or false
- */
- public boolean areAllBrandsDisplayed(List<WebElement> brandsBefore, List<WebElement> brandsAfter){
- boolean equal = false;
- String brandNameBefore, brandNameAfter;
- if(brandsBefore.size() == brandsAfter.size()){
- for(int i = 0; i < brandsBefore.size(); i++){
- brandNameBefore = brandsBefore.get(i).getText();
- brandNameAfter = brandsAfter.get(i).getText();
- if(!brandNameBefore.equals(brandNameAfter)){
- return equal;
- }
- }
- return true;
- }
- return equal;
- }
- /**
- * Checks if all regions are displayed correctly or not.
- *
- * @param regionsListFromFilter
- * @param regionsGroupList
- *
- * @return true or false
- */
- public boolean areAllRegionsDisplayed(List<WebElement> regionsListFromFilter, List<WebElement> regionsGroupList){
- String lastElementText = regionsGroupList.get(regionsGroupList.size() - 1).getText();
- int numberOfNotAssignedRegions, numberOfRegionsFromSearchFilter, numberOfAssignedRegions;
- numberOfAssignedRegions = regionsGroupList.size();
- numberOfRegionsFromSearchFilter = regionsListFromFilter.size();
- boolean equal = false;
- if(lastElementText.contains(" Regions with no social accounts associated")){
- numberOfAssignedRegions--;
- numberOfNotAssignedRegions = numberOfRegionsFromSearchFilter - numberOfAssignedRegions;
- if(lastElementText.equals(numberOfNotAssignedRegions + " Regions with no social accounts associated")){
- equal = true;
- }
- }else if(numberOfAssignedRegions == numberOfRegionsFromSearchFilter){
- equal = true;
- }
- return equal;
- }
- /**
- * Checks if all countries are displayed correctly or not.
- *
- * @param countriesListFromFilter
- * @param countriesGroupList
- *
- * @return true or false
- */
- public boolean areAllCountriesDisplayed(List<WebElement> countriesListFromFilter, List<WebElement> countriesGroupList){
- String lastElementText = countriesGroupList.get(countriesGroupList.size() - 1).getText();
- int numberOfNotAssignedCountries, numberOfCountriesFromSearchFilter, numberOfAssignedCountries;
- numberOfAssignedCountries = countriesGroupList.size();
- numberOfCountriesFromSearchFilter = countriesListFromFilter.size();
- boolean equal = false;
- if(lastElementText.contains(" Countries with no social accounts associated")){
- numberOfAssignedCountries--;
- numberOfNotAssignedCountries = numberOfCountriesFromSearchFilter - numberOfAssignedCountries;
- if(lastElementText.equals(numberOfNotAssignedCountries + " Countries with no social accounts associated")){
- equal = true;
- }
- }else if(numberOfAssignedCountries == numberOfCountriesFromSearchFilter){
- equal = true;
- }
- return equal;
- }
- /**
- * Checks if needed account is assigned to owner or not.
- *
- * @param accountName
- *
- * @return true or false
- */
- public boolean isAccountOwnerAssigned(String accountName){
- WebElement owner;
- String ownerName;
- owner = socialProfileForm.findElement(By.xpath("//*[contains(normalize-space(text()),'" + accountName + "')]/../../td[@class='user']"));
- ownerName = owner.getText();
- if(ownerName.equals("+ assign acct owner")){
- return false;
- }
- return true;
- }
- /**
- * Gets account platform type name.
- *
- * @param accountName
- *
- * @return platform name
- */
- public String getAccountPlatformType(String accountName){
- WebElement platform;
- String attribute, platformName;
- platform = socialProfileForm.findElement(By.xpath(".//span[text()='" + accountName + "']/../../../.."));
- attribute = platform.getAttribute("id");
- platformName = attribute.substring(0, attribute.lastIndexOf("_"));
- return platformName;
- }
- /**
- * Clicks 'Account' filter.
- *
- * @return AccountFilter object
- */
- public AccountFilter clickAccountFilter(){
- accountFilerLink.click();
- return new AccountFilter(driver);
- }
- /**
- * Clicks [CompanyAssosiations] tab.
- *
- * @return CompanyPortfolioPage object
- */
- public CompanyPortfolioPage clickCompanyAssosiationsTab(){
- companyAssosiationsTab.click();
- return new CompanyPortfolioPage(driver);
- }
- /**
- * Gets region name on the [CompanyAssosiations] tab.
- *
- * @return region name.
- */
- public String getRegionNameFromCompanyAssosiationsTab(){
- String region;
- clickCompanyAssosiationsTab();
- region = regionName.getText();
- return region;
- }
- public String getSubsidiaryNameFromCompanyAssosiationsTab(){
- String subsidiary;
- clickCompanyAssosiationsTab();
- subsidiary = subsidiaryName.getText();
- return subsidiary;
- }
- }
Add Comment
Please, Sign In to add comment