Guest User

Untitled

a guest
Oct 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 82.20 KB | None | 0 0
  1. package com.dachisgroup.sbi.pages.companyPortfolio;
  2.  
  3. import java.io.IOException;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.Collections;
  7. import java.util.Iterator;
  8. import java.util.List;
  9.  
  10. import org.openqa.selenium.By;
  11. import org.openqa.selenium.Dimension;
  12. import org.openqa.selenium.JavascriptExecutor;
  13. import org.openqa.selenium.NoSuchElementException;
  14. import org.openqa.selenium.WebDriver;
  15. import org.openqa.selenium.WebElement;
  16. import org.openqa.selenium.support.FindBy;
  17. import org.openqa.selenium.support.PageFactory;
  18. import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
  19. import org.openqa.selenium.support.pagefactory.ElementLocatorFactory;
  20.  
  21. import com.dachisgroup.sbi.filtersBlock.AccountFilter;
  22. import com.dachisgroup.sbi.filtersBlock.BrandsFilter;
  23. import com.dachisgroup.sbi.filtersBlock.DepartmentsFilter;
  24. import com.dachisgroup.sbi.filtersBlock.OwnersFilter;
  25. import com.dachisgroup.sbi.filtersBlock.PlatformsFilter;
  26. import com.dachisgroup.sbi.filtersBlock.RegionsFilter;
  27. import com.dachisgroup.sbi.filtersBlock.SubsidiariesFilter;
  28. import com.dachisgroup.sbi.init.Common;
  29. import com.dachisgroup.sbi.init.CoreApi;
  30. import com.dachisgroup.sbi.init.ElementLocators;
  31. import com.dachisgroup.sbi.pages.ImportSocialAccountsForm;
  32. import com.dachisgroup.sbi.pages.UserParentPage;
  33.  
  34.  
  35. public class CompanyPortfolioPage extends UserParentPage implements ElementLocators{
  36.    
  37.     Common common = new Common(driver);
  38.     CoreApi coreApi = new CoreApi();
  39.    
  40.     /**
  41.      * Define elements on CompanyPortfolioPage.
  42.      */
  43.    
  44.    
  45.     @FindBy(id="socialProfile")
  46.     private WebElement socialProfileForm;
  47.    
  48.     @FindBy(xpath="//dd[@id='Facebook_dd']")
  49.     private WebElement socAccountname;
  50.    
  51.     @FindBy(xpath="//div[@id='loadAccounts']")
  52.     private WebElement accountLoads;
  53.    
  54.     @FindBy(css=".sicoalFilterSelected.easy-clearing")
  55.     private WebElement selectedFilters;
  56.    
  57.     @FindBy(css=".inner.easy-clearing")
  58.     private WebElement cpForm; 
  59.    
  60.    
  61.     @FindBy(xpath=".//tr[@class='open']")
  62.     private List<WebElement> allListPage;
  63.    
  64.     @FindBy(xpath="//td[@class='Audience']")
  65.     private List<WebElement> audienceList; 
  66.    
  67.     @FindBy(xpath=".//tbody/tr/td/div/ul[1]/li[2]")
  68.     private List<WebElement> listOfBraindsInDetails;
  69.    
  70.     @FindBy(xpath=".//*[@id='selectedFilters']/div/ul/li/div")
  71.     private List<WebElement> listOfSelectedFilters;
  72.    
  73.     @FindBy(xpath="//*[@id='socialProfile']/div/p")
  74.     private WebElement selectedFiltersTitle;
  75.    
  76.     @FindBy(xpath=".//*/tbody/tr/td/div/ul[1]/li")
  77.     private List<WebElement> listOfAccountDetails;
  78.    
  79.     @FindBy(xpath=".//*[@id='Associations']/dd[2]/p/span")
  80.     private List <WebElement> regions;
  81.    
  82.     @FindBy(xpath=".//td[@class='Audience']")
  83.    
  84.     private List <WebElement> listofAudience;
  85.    
  86.     @FindBy (xpath="//tr[@class='open']")
  87.     private List <WebElement> listofaccount;
  88.    
  89.     @FindBy (xpath=".//*[@id='col_audience']")
  90.     private List <WebElement> columnAudience;
  91.    
  92.     @FindBy(xpath=".//h3[contains(.,'add')]")
  93.     private List <WebElement> listofSoc;
  94.    
  95.     @FindBy(css=".leftArrow")
  96.     private List <WebElement> listofSocials;
  97.    
  98.     @FindBy (xpath=".//tbody/tr/td/div/ul/li[3]/span")
  99.     private WebElement ownersSpan;
  100.     @FindBy(css=".name")
  101.     private List<WebElement> listOfFilters;
  102.    
  103.     @FindBy (xpath="//span[contains(@class,'withoutDisplayName')]")
  104.     private List<WebElement> accountlist;
  105.    
  106.     @FindBy (css=".user>a")
  107.     private List<WebElement>listofAssigns;
  108.    
  109.     @FindBy (css=".noneArrow")
  110.     private List <WebElement> emptySocExpand;
  111.    
  112.     @FindBy(css=".socialProfileList.easy-clearing>h3")
  113.     private WebElement employeeAccountsBlock;
  114.    
  115.     @FindBy(xpath="//a[@class='profileSettings']")
  116.     private WebElement importExportLink;
  117.    
  118.     @FindBy(xpath=".//*[@id='socialProfile']/dl/dt/form/ul/li[3]/div")
  119.     private WebElement importExportWindow;
  120.    
  121.     @FindBy(linkText="Export Results")
  122.     private WebElement exportResultsLink;
  123.    
  124.     @FindBy(xpath="//ul[@style='display: block;']//a[contains(text(),'Edit')]")
  125.     private WebElement edit;
  126.    
  127.     @FindBy(linkText="Import Accounts")
  128.     private WebElement importAccountsLink;
  129.    
  130.     // filters block elements.
  131.     @FindBy(css=".clearAll")
  132.     private WebElement clearAllFiltersHref;
  133.    
  134. //  @FindBy(css="name:contains('Platforms')")
  135.     @FindBy(xpath="//span[contains(text(), 'Platforms')]")
  136.     private WebElement platformsLink;
  137.    
  138.     @FindBy(xpath="//form/ul/li/span[contains(text(), 'Brands')]")
  139.     private WebElement brandFormLink;
  140.    
  141.     @FindBy(xpath="//form/ul/li/span[contains(text(), 'Owners')]")
  142.     private WebElement ownersFormLink;
  143.    
  144.     @FindBy(xpath="//ul/li/span[contains(text(), 'Regions')]")
  145.     private WebElement regionsFormLink;
  146.    
  147.     @FindBy(xpath="//form/ul/li/span[contains(text(), 'Subsidiaries')]")
  148.     private WebElement subsidiariesFormLink;
  149.    
  150.     @FindBy(xpath="//form/ul/li/span[contains(text(), 'Departments')]")      
  151.     private WebElement departmentsFormLink;
  152.    
  153.     @FindBy(xpath="//li[contains(@class,'hover')]//label[not(contains(@for,'country'))]")
  154.     private List<WebElement> filterLabels;
  155.    
  156.     @FindBy(xpath="//li[contains(@class,'hover')]//input[not(contains(@class,'country'))]")
  157.     private List<WebElement> filterCheckboxes;
  158.    
  159.     // Social Profiles List elements.
  160. //  @FindBy(css=".socialProfileList.easy-clearing")  tmp decision
  161.     @FindBy(css=".leftArrow")
  162.     private List<WebElement> socialAccountsList;
  163.    
  164.     @FindBy(css=".socialProfileList.easy-clearing>h3")
  165. //  @FindBy(css=".leftArrow")
  166.     private List<WebElement> socialAccount;
  167.    
  168.     @FindBy(id="Unassigned_dd")
  169. //  @FindBy(css=".leftArrow")
  170.     private WebElement leftArrow;
  171.    
  172.    
  173.     @FindBy(css=".accountName")
  174.     private List<WebElement> accountUserList;
  175.    
  176.     @FindBy(css=".account_description")
  177.     private WebElement accountDescription;
  178.    
  179.     @FindBy(css=".user")
  180.     private List<WebElement> ownersList;
  181.    
  182.     @FindBy(css=".childInfo.easy-clearing>p>a")
  183.     private WebElement companyProfileTabLink;
  184.    
  185.     @FindBy(xpath =".//span[contains(text(), 'Brands')]/parent::*/*/*/a[contains(text(),'Show Results')]")
  186.     private WebElement showResultButton;
  187.    
  188.     @FindBy (xpath=".//span[@class='withoutDisplayName']")
  189.     private List<WebElement> listOfNames;
  190.  
  191. //  @FindBy(xpath="//a[@class='button' and contains(text(), 'Add Social Accounts')]") (*by Dima R)
  192.     @FindBy(css=".button[onclick*='add']")
  193.     private WebElement addSocialAccountsButton;
  194.    
  195. //  @FindBy(xpath="//a[@class='button' and " +
  196. //  "contains(text(), 'Invite Your Coworkers')]")  (*by Dima R)
  197.     @FindBy(css=".button[onclick*='invite']") //link=Invite Your Coworkers
  198.     private WebElement inviteYourCoworkersButton;
  199.    
  200.     @FindBy(css="input[id='nameSearch']")
  201.     private WebElement searchField;
  202.    
  203.     @FindBy(xpath="//input[@value='Search']")
  204.     private WebElement searchButton;
  205.  
  206.     @FindBy(css="div[id='delete']")
  207.     private WebElement closeButton;
  208.    
  209.     @FindBy(css="#pivotBy")
  210.     private WebElement platformsListFromDropdownMenu;
  211.    
  212.     @FindBy(css="#pivotBy>option")
  213.     private List<WebElement> pivotFiltersList;
  214.    
  215. //  @FindBy(css="#col_name>span")
  216.     @FindBy(css="#col_name")
  217.     private List <WebElement> accountNameColumnSpan;
  218.    
  219.     @FindBy(css="#col_owner")
  220.     private WebElement userColumnSpan;
  221.    
  222.     @FindBy(css="#col_audience")
  223.     private WebElement audienceColumnSpan;
  224.    
  225.     @FindBy(xpath="//th[@id='col_signal']")
  226.     private WebElement conversationStrengthColumnSpan;
  227.    
  228.     @FindBy(xpath="//dd[@id='Twitter_dd']/table/thead/tr/th[@id='col_signal']")
  229.     private WebElement conversationStrengthColumnTwitter;
  230.    
  231.    
  232.     @FindBy(css="#col_percentComplete")
  233.     private WebElement percentCompleteColumnSpan;
  234.    
  235.     //expanded social account elements
  236.     @FindBy(xpath="//a[contains(.,'http')]")
  237.     private WebElement socialAccountLink;
  238.    
  239.     @FindBy(css=".editAssign>a")
  240.     private WebElement editAccountLink;
  241.    
  242.     @FindBy(css=".editAssign>a")
  243.     private List <WebElement> listEditAccountLinks;
  244.    
  245.     @FindBy(css=".profilemessage>a")
  246.     private WebElement messageThisUserLink;
  247.    
  248.     @FindBy(css=".delete>a")
  249.     private WebElement deleteThisAccountLink;
  250.    
  251.     @FindBy(linkText="Settings")
  252.     private WebElement settingsButton;
  253.    
  254.     @FindBy(xpath="//div[@class='settingsMenu']")
  255.     private WebElement settingsMenu;
  256.    
  257.     @FindBy(css="#Facebook_dd .preview")
  258.     private WebElement topQuestionMarkImg;
  259.    
  260.     @FindBy(css="#benchmarkingBar")
  261.     private List<WebElement> benchmarkingBarsList;
  262.    
  263.     @FindBy(css=".industryAverage")
  264.     private List<WebElement> industryAverageList;
  265.    
  266.     @FindBy(id="trborder")
  267.     private WebElement redBorder;
  268.    
  269.     @FindBy(xpath="//img[@alt='LinkedIn']")
  270.     private WebElement linkedinImg;
  271.  
  272.     @FindBy(xpath="//span[contains(text(), 'Account')]")      
  273.     private WebElement accountFilerLink;
  274.  
  275.     @FindBy(xpath="//span[contains(text(), 'Demographics')]")      
  276.     private WebElement demographicsFilerLink;
  277.    
  278.     @FindBy(xpath="//li[text()='Company Associations']")
  279.     private WebElement companyAssosiationsTab;
  280.    
  281.     @FindBy(xpath="//dd[@class='advocate-associations-title easy-clearing']/span[text()='Regions']/following-sibling::*")
  282.     private WebElement regionName;
  283.    
  284.     @FindBy(xpath="//dd[@class='advocate-associations-title easy-clearing']/span[text()='Subsidiaries']/following-sibling::*")
  285.     private WebElement subsidiaryName;
  286.    
  287.     /**
  288.      * Initialize CompanyPortfolioPage.
  289.      *
  290.      * @param driver Driver for Selenium2.
  291.      * @throws InterruptedException
  292.      */
  293.     public CompanyPortfolioPage(WebDriver driver){
  294.         super(driver);
  295.         ElementLocatorFactory finder = new
  296.                 AjaxElementLocatorFactory(driver, DRIVER_WAIT);
  297.                     PageFactory.initElements(finder, this);
  298.                     this.driver = driver;
  299.                     common.waitForAjax();  
  300.                     common.waitForElement(".name");
  301.                     try{
  302.                         common.waitForElementHide(".//*[@id='curtain_loading']");
  303.                     }
  304.                     catch(Exception e){
  305.                        
  306.                     }
  307.     }  
  308.     /**
  309.      * gets Group:by value.
  310.      *
  311.      * @return          value.
  312.      */
  313.     public String getGroupByValue(){       
  314.         String value = platformsListFromDropdownMenu.getAttribute("value");
  315.                 System.out.println(value);             
  316.         return value;
  317.     }
  318.    
  319.     /**
  320.      * Fills needed search term.
  321.      *
  322.      * @param searchTerm    Search account term.
  323.      */
  324.     public void fillAndSearchSearchTerm(String searchTerm){
  325.         logger.debug("Fill data for search with following value: <br>" +
  326.                 "Search account term - " + searchTerm);
  327.        
  328.         searchField.clear();
  329.         searchField.sendKeys(searchTerm);  
  330.     }
  331.    
  332.     /**
  333.      * Search accounts by specific term.
  334.      *
  335.      * @param searchTerm    Needed search term.
  336.      *
  337.      * @return  CompanyPortfolioPage object.
  338.      */
  339.     public CompanyPortfolioPage searchAccount(String searchTerm){
  340.         fillAndSearchSearchTerm(searchTerm);
  341.         searchButton.click();
  342.         return new CompanyPortfolioPage(driver);       
  343.     }
  344.    
  345.     /**
  346.      * Cancel search filter.
  347.      *
  348.      * @param searchTerm    Needed search term.
  349.      *
  350.      * @return  CompanyPortfolioPage.
  351.      *
  352.      * @throws  InterruptedException.
  353.      */
  354.     public CompanyPortfolioPage cancelSearchFilter(String searchTerm) throws InterruptedException{
  355.         fillAndSearchSearchTerm(searchTerm);
  356.         this.clickSearchButton();
  357.         this.clickCloseButton();
  358.         return new CompanyPortfolioPage(driver);       
  359.     }
  360.    
  361.    
  362.     /**
  363.      * Clicks Search button
  364.      *
  365.      * @return CompanyPortfolioPage object
  366.      */
  367.     public CompanyPortfolioPage clickSearchButton(){
  368.         logger.debug("Click [Search] button ");
  369.        
  370.         searchButton.click();
  371.         return new CompanyPortfolioPage(driver);
  372.     }
  373.    
  374.    
  375.     /**
  376.      * Clicks Close button
  377.      *
  378.      * @return CompanyPortfolioPage object
  379.      */
  380.     public CompanyPortfolioPage clickCloseButton(){
  381.         logger.debug("Click [Close] button ");
  382.        
  383.         closeButton.click();
  384.         return new CompanyPortfolioPage(driver);
  385.     }
  386.    
  387.     /**
  388.      * Selects random platform from the "Group by:" drop-down menu.
  389.      *
  390.      * @return  CompanyPortfolioPage object.
  391.      */
  392.     public CompanyPortfolioPage clickRandomPlatformFormDropdownMenu(){
  393.         logger.debug("Click random filter in the drop down menu ");
  394.        
  395.         WebElement randomFilter;
  396.         platformsListFromDropdownMenu.click();
  397.         randomFilter = common.randomElementFromTheList(pivotFiltersList);
  398.         randomFilter.click();
  399.         return new CompanyPortfolioPage(driver);       
  400.     }
  401.    
  402.     /**
  403.      * Selects needed platform from the "Pivot by:" drop-down menu.
  404.      *
  405.      * @param   Needed platform
  406.      *
  407.      * @return  CompanyPortfolioPage object.
  408.      * @throws  InterruptedException.
  409.      */
  410.     public CompanyPortfolioPage clickPlatformFormDropdownMenu(String platform){
  411.         logger.debug("Select needed drop down menu item with following value: <br>" +
  412.                 "Needed platform - " + platform);
  413.        
  414.         common.select(platformsListFromDropdownMenu, platform);
  415.         return new CompanyPortfolioPage(driver);
  416.     }
  417.    
  418.     /**
  419.      * Finds and clicks needed social network.
  420.      *
  421.      * @param socialNetworkName.
  422.      *
  423.      * @return CompanyPortfolioPage object.
  424.      */
  425.    
  426.     public CompanyPortfolioPage findAndCheckNeededSocialNetwork(String socialNetworkName ){
  427.         WebElement socialNetworkHeader;
  428.         String socialNetwork;
  429.         socialNetwork = "//dd[@id='" + socialNetworkName + "_dd']/h3";
  430.         socialNetworkHeader = accountLoads.findElement(By.xpath(socialNetwork));
  431.         if(accountlist.size() == 0){
  432.             socialNetworkHeader.click();
  433.         }
  434.         return new CompanyPortfolioPage(driver);
  435.     }
  436.  
  437.     /**
  438.      * Finds and clicks needed social profile.
  439.      *
  440.      * @param socialProfileName.
  441.      *
  442.      * @return CompanyPortfolioPage.
  443.      */
  444.    
  445.     public CompanyPortfolioPage findAndCheckNeededSocialProfile(String socialProfileName ){
  446.         WebElement socialProfileHeader;
  447.         socialProfileHeader = common.getHeaderElement(socialProfileName);
  448.         socialProfileHeader.click();
  449.         return new CompanyPortfolioPage(driver);
  450.     }
  451.    
  452.    
  453.     /**
  454.      * Finds needed symbol in socialprofileName.
  455.      *
  456.      * @param       socialProfileName.
  457.      *
  458.      * @param       character
  459.      *
  460.      * @return      true or false.
  461.      */
  462.     public boolean findAndCheckSymbol(String socialProfileName, String character ){
  463.         WebElement socialProfileHeader;
  464.         String headerTextChar;
  465.         socialProfileHeader = socialProfileForm.findElement(By.cssSelector(cssTwitterAccountName));
  466.         String headertext = socialProfileHeader.getText().toString();
  467.         headerTextChar = headertext.substring(1, 2);
  468.         if(!headerTextChar.equals(character))
  469.         {
  470.             return false;
  471.         }
  472.         else
  473.  
  474.         return true;
  475.     }  
  476.            
  477.     /**
  478.      * Checks if  the account is found.  *
  479.      *
  480.      * @return      true or false.
  481.      */
  482.     public boolean findAccount(){
  483.         if(accountUserList.isEmpty()){
  484.             return false;
  485.         }
  486.         else
  487.  
  488.         return true;
  489.     }
  490.  
  491.    
  492.     /**
  493.      * Clicks on the needed social network and then clicks [Show more accounts] links
  494.      *
  495.      * @param socialProfileName Social profile name.
  496.      *
  497.      * @return  CompanyPortfolioPage object.
  498.      *
  499.      */
  500.     public CompanyPortfolioPage clickShowMoreAccountsLink(String socialProfolioName){
  501.         logger.debug("Click [Show More Accounts] link with following social network: <br>" +
  502.                 "social network - " + socialProfolioName);
  503.        
  504.         WebElement showMore;
  505.         findAndCheckNeededSocialNetwork(socialProfolioName);
  506.         showMore = socialProfileForm.findElement(By.xpath(".//*[@id='" + socialProfolioName + "_more']/td"));
  507.         showMore.click();
  508.         return new CompanyPortfolioPage(driver);   
  509.     }
  510.    
  511.     /**
  512.      * Clicks on the needed social network and then clicks [Show more accounts] links until all are shown
  513.      *
  514.      * @param socialProfileName Social profile name.
  515.      *
  516.      * @return  CompanyPortfolioPage object.
  517.      */
  518.     public CompanyPortfolioPage clickShowAllAccounts(String socialProfolioName){
  519.         logger.debug("Click Show All Accounts with following social network: <br>" +
  520.                 "social network - " + socialProfolioName);
  521.        
  522.         WebElement showMore;
  523.         this.findAndCheckNeededSocialNetwork(socialProfolioName);
  524.         showMore = socialProfileForm.findElement(By.xpath(".//*[@id='"+socialProfolioName+"_more']/td"));
  525.         if(showMore.isDisplayed()){
  526.             while(showMore.isDisplayed()){
  527.                 this.clickWithPageReturn(showMore);
  528.             }  
  529.         }
  530.         return new CompanyPortfolioPage(driver);   
  531.     }
  532.    
  533.     /**
  534.      * Clicks [Show More] for network.
  535.      *
  536.      * @param socialProfolioName
  537.      *
  538.      * @return CompanyPortfolioPage object.
  539.      */
  540.     public CompanyPortfolioPage clickShowMoreForNetwork(String socialProfolioName){
  541.         logger.debug("Click [Show More] for network with following value: <br>" +
  542.                 "social network - " + socialProfolioName);
  543.        
  544.         try{
  545.             WebElement showMore = socialProfileForm.findElement(By.xpath(".//*[@id='" + socialProfolioName + "_more']/td"));
  546.             this.clickWithPageReturn(showMore);
  547.         }
  548.         catch(Exception e){
  549.            
  550.         }
  551.         return new CompanyPortfolioPage(driver);
  552.     }
  553.    
  554.     /**
  555.      * Clicks Show More Link for speciefied
  556.      * social network while it displayed.
  557.      *
  558.      * @param socialProfileName         name of social network.
  559.      *
  560.      * @return                          CompanyPortfolioPage object.
  561.      */
  562.     public CompanyPortfolioPage clickShowMoreWhileDisplayed(String socialProfileName){
  563.         logger.debug("Click [Show More] link for specified social profile <br>with following value: <br>" +
  564.                 "social progile name - " + socialProfileName);
  565.        
  566.         if(accountlist.size() == 0){
  567.             this.findAndCheckNeededSocialNetwork(socialProfileName);
  568.         }
  569.         try{
  570.             WebElement showMore = socialProfileForm.findElement(By.xpath(".//*[@id='" + socialProfileName + "_more']/td"));
  571.             do{
  572.                 this.clickWithPageReturn(showMore);
  573.             }  
  574.             while(common.isElementDisplayed(showMore));
  575.         }
  576.         catch(Exception e){        
  577.         }
  578.         return new CompanyPortfolioPage(driver);
  579.     }
  580.    
  581.     /**
  582.      * Clicks Show all accounts.
  583.      *
  584.      * @return      CompanyPortfolioPage object.
  585.      */
  586.     public CompanyPortfolioPage clickShowAllAccounts() {
  587.         logger.debug("Click show all accounts");
  588.        
  589.         for(WebElement socialPlatform : socialAccountsList){
  590.             String socialPLatformName = socialPlatform.getText().replaceAll(" ","");
  591.             String correctName = socialPLatformName.substring(0,socialPLatformName.indexOf("("));
  592.             this.clickShowAllAccounts(correctName);
  593.         }
  594.         return new CompanyPortfolioPage(driver);
  595.     }
  596.    
  597.     /**
  598.      * Compares number of accounts in list with number of accounts written in SocialNetworkHeader
  599.      *
  600.      * @param socialProfileName Social profile name.
  601.      *
  602.      * @return  CompanyPortfolioPage object.
  603.      *
  604.      */
  605.     public boolean findAndCheckDigits(String SocialNetworkName) {
  606.         WebElement listofaccount1;
  607.         String socialprofileName = ".//dd[@id='" + SocialNetworkName + "_dd']";
  608.         listofaccount1 = socialProfileForm.findElement(By.xpath(socialprofileName));
  609.         String headertext = listofaccount1.getText().toString();
  610.         int listLength = listofaccount.size();
  611.         int accountsCount = Integer.parseInt(headertext.substring(
  612.                 headertext.indexOf("(") + 1, headertext.indexOf(")")));
  613.         if (listLength != accountsCount) {
  614.             return false;
  615.         } else
  616.             return true;
  617.     }
  618.  
  619.    
  620.  
  621.  
  622.  
  623.     /**
  624.      * Clicks on the needed social network and then sorts data by
  625.      * clicking on the [Account Name] column head name.
  626.      *
  627.      * @param socialProfileName Social profile name.
  628.      *
  629.      * @return  CompanyPortfolioPage object.
  630.      *
  631.      * @throws  InterruptedException.
  632.      */
  633.     public CompanyPortfolioPage clickAccountNameColumnSpan(String socialPortfolioName) throws InterruptedException{
  634.         logger.debug("Click name column span with next value: <br>" +
  635.                 "social network - " + socialPortfolioName);
  636.        
  637.         WebElement accNameColumnSpan;
  638.         findAndCheckNeededSocialNetwork(socialPortfolioName);    
  639.         accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName +"_table']/*/*/th[@id='col_name']/span"));
  640.         accNameColumnSpan.click();
  641.         return new CompanyPortfolioPage(driver);
  642.     }
  643.    
  644.     /**
  645.      * Clicks on the needed social network and then sorts data
  646.      * by clicking on the [User/Owner] column head name.
  647.      *
  648.      * @param socialProfileName Social profile name.
  649.      *
  650.      * @return  CompanyPortfolioPage object.
  651.      */
  652.     public CompanyPortfolioPage clickUserColumnSpan(String socialPortfolioName){
  653.         logger.debug("Click on the [User/Owner] column head name with following value: <br>" +
  654.                         "social network - " + socialPortfolioName);
  655.  
  656.        
  657.         WebElement accNameColumnSpan;
  658.         findAndCheckNeededSocialNetwork(socialPortfolioName);
  659.         accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName + "_table']/*/*/th[@id='col_owner']"));
  660.         accNameColumnSpan.click();
  661.         return new CompanyPortfolioPage(driver);
  662.     }
  663.    
  664.     /**
  665.      * Clicks on the needed social network and then sorts data
  666.      * by clicking on the [User/Owner] column head name.
  667.      *
  668.      * @param socialProfileName Social profile name.
  669.      *
  670.      * @return  CompanyPortfolioPage object.
  671.      */
  672.     public CompanyPortfolioPage clickUserColumnSpanWithoutSocialNetworkExpand(String socialPortfolioName){
  673.         logger.debug("Click on the [User/Owner] column head name without network expand " +
  674.                 "with next value: " +
  675.                 "social network - " + socialPortfolioName + "");
  676.        
  677.         WebElement accNameColumnSpan;
  678.         accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName + "_table']/*/*/th[@id='col_owner']"));
  679.         accNameColumnSpan.click();
  680.         return new CompanyPortfolioPage(driver);
  681.     }
  682.    
  683.     /**
  684.      * Clicks on the needed social network and then sorts data
  685.      * by clicking on the [Audience] column head name.
  686.      *
  687.      * @param socialProfileName Social profile name.
  688.      *
  689.      * @return  CompanyPortfolioPage object.
  690.      *
  691.      * @throws  InterruptedException.
  692.      */
  693.     public CompanyPortfolioPage clickAudienceColumnSpan(String socialPortfolioName) throws InterruptedException{
  694.         logger.debug("Click [Audience] column head name <br>" +
  695.                 "with following value: <br>" +
  696.                 "social network - " + socialPortfolioName);
  697.        
  698.         WebElement accNameColumnSpan;
  699.         findAndCheckNeededSocialNetwork(socialPortfolioName);
  700.         accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName + "_table']/*/*/th[@id='col_audience']/span"));
  701.         accNameColumnSpan.click();
  702.         return new CompanyPortfolioPage(driver);
  703.     }
  704.    
  705.     /**
  706.      * Clicks on the needed social network and then sorts data
  707.      * by clicking on the [Conversation Strength] column head name.
  708.      *
  709.      * @param socialProfileName Social profile name.
  710.      *
  711.      * @return  CompanyPortfolioPage object.
  712.      */
  713.     public CompanyPortfolioPage clickConversationStrnghtColumnSpan(String socialPortfolioName){
  714.         logger.debug("Click [Conversation Strength] column head name <br>" +
  715.                 "with following value: <br>" +
  716.                 "social network - " + socialPortfolioName);
  717.        
  718.         WebElement accNameColumnSpan;
  719.         findAndCheckNeededSocialNetwork(socialPortfolioName);
  720.         accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+ socialPortfolioName + "_table']/*/*/th[@id='col_signal']"));
  721.         accNameColumnSpan.click();
  722.         return new CompanyPortfolioPage(driver);
  723.     }
  724.    
  725.     /**
  726.      * Clicks on the needed social network and then sorts data
  727.      * by clicking on the [Percent Complete] column head name.
  728.      *
  729.      * @param socialProfileName Social profile name.
  730.      *
  731.      * @return  CompanyPortfolioPage object.
  732.      *
  733.      * @throws  InterruptedException.
  734.      */
  735.     public CompanyPortfolioPage clickPercentCompleteColumnSpan(String socialPortfolioName) throws InterruptedException{
  736.         logger.debug("Click [Percent Complete] column head name <br>" +
  737.                 "with following value: <br>" +
  738.                 "social network - " + socialPortfolioName);
  739.        
  740.         WebElement accNameColumnSpan;
  741.         findAndCheckNeededSocialNetwork(socialPortfolioName);
  742.         accNameColumnSpan = socialProfileForm.findElement(By.xpath(".//table[@id='"+socialPortfolioName+"_table']/*/*/th[@id='col_percentComplete']/span"));
  743.         accNameColumnSpan.click();
  744.         return new CompanyPortfolioPage(driver);
  745.     }
  746.    
  747.     /**
  748.      * Gets percentage of account
  749.      *
  750.      * @param accountName
  751.      *
  752.      * @return percentage
  753.      */
  754.     public int getPercentComplete(String accountName){
  755.         WebElement account = socialProfileForm.findElement(By.xpath(".//span[contains(.,'" + accountName + "')]"));
  756.     //  WebElement account = socialProfileForm.findElement(By.xpath("//span[@class='withoutDisplayName'][contains(.,'" + accountName + "')]"));
  757.         WebElement percent = account.findElement(By.xpath(xpathPercentComplete));
  758.         //String text = percent.getAttribute("textContent");
  759.         String text = percent.getText();
  760.         String percentText = text.substring(0, text.indexOf("%"));
  761.         int nPercent = Integer.parseInt(percentText);
  762.         return nPercent;
  763.     }
  764.    
  765.     /**
  766.      * Gets percentage of account in text format
  767.      *
  768.      * @param accountName Name of account
  769.      *
  770.      * @return Text with percentage
  771.      */
  772.     public String getTextPercentComplete(String accountName){
  773.         WebElement percent = socialProfileForm.findElement(By.xpath(".//span[text()='"+ accountName +"']/../..//p[@class='percentComplete']"));
  774.         String text = percent.getText();
  775.         return text;
  776.     }
  777.    
  778.     /**
  779.      * Clicks on random social accounts toggle.
  780.      *
  781.      * @return CompanyPortfolioPage object.
  782.      */
  783.     public CompanyPortfolioPage expandRandomSocExpand(){
  784.         logger.debug("Expand random social account ");
  785.        
  786.         WebElement randSocExpand;
  787.         randSocExpand = common.randomElementFromTheList(socialAccountsList);
  788.         randSocExpand.click();
  789.         return new CompanyPortfolioPage(driver);     
  790.     }
  791.    
  792.    
  793.     /**
  794.      * Gets list of account names in Social Network.
  795.      *
  796.      * @param socialProfolioName        social profile name.       
  797.      *
  798.      * @param sortBy                    sort account by option.
  799.      *
  800.      * @return list of account names    list of names. 
  801.      */
  802.     public ArrayList<String> getAccountsNames(String socialProfolioName,
  803.             String sortBy) {
  804.         String listOfElementsPath = null;
  805.  
  806.         if (sortBy.equals("Account Name")) {
  807.             listOfElementsPath = ".//table[@id='" + socialProfolioName
  808.                     + "_table']//td[@class='accountName']";
  809.  
  810.         } else if (sortBy.equals("User")) {
  811.             listOfElementsPath = ".//table[@id='" + socialProfolioName
  812.                     + "_table']//td[@class='user']";
  813.  
  814.         } else if (sortBy.equals("Audience")) {
  815.             listOfElementsPath = ".//table[@id='" + socialProfolioName
  816.                     + "_table']//td[@class='Audience']";
  817.  
  818.         } else if (sortBy.equals("Conversation")) {
  819.             listOfElementsPath = ".//table[@id='" + socialProfolioName
  820.                     + "_table']//td[@class='signal']/div";
  821.         }
  822.  
  823.         List<WebElement> ownersList = socialProfileForm.findElements(By
  824.                 .xpath(listOfElementsPath));
  825.         ArrayList<String> collectionSort = new ArrayList<String>();
  826.  
  827.         for (WebElement element : ownersList) {
  828.             String name = element.getText();
  829.             String lowerCaseName = name.toLowerCase();
  830.             if (lowerCaseName.indexOf("more") != -1) {
  831.                 String correctName = lowerCaseName.substring(lowerCaseName
  832.                         .indexOf("\n") + 1);
  833.                 collectionSort.add(correctName);
  834.             } else
  835.                 collectionSort.add(lowerCaseName);
  836.         }
  837.         return collectionSort;
  838.     }
  839.    
  840.    
  841.     /**
  842.      * Sorts account list using collection sorting.
  843.      *
  844.      * @param sortingList       List to sort.
  845.      *
  846.      * @return sorted list      Sorted list.
  847.      */
  848.     public ArrayList<String> sortAccounts(ArrayList<String> sortingList) {
  849.         int numbers = 0;
  850.         for (String name : sortingList) {
  851.             if (name.matches("\\d+")) {
  852.                 numbers++;
  853.             }
  854.         }
  855.         Collections.sort(sortingList);
  856.  
  857.         if (numbers == sortingList.size()) {
  858.             Collections.reverse(sortingList);
  859.         }
  860.        
  861.         return sortingList;
  862.     }
  863.  
  864.    
  865.     /**
  866.      * Compares two accounts lists.
  867.      *
  868.      * @param first list.
  869.      *
  870.      * @param second list.
  871.      *
  872.      * @return true if lists are equal or false if not.
  873.      */
  874.     public boolean isSortingOrderCorrect(ArrayList<String> collection,
  875.             ArrayList<String> site) {
  876.         Iterator<String> collectionSortIterator = collection.iterator();
  877.         Iterator<String> siteSortIterator = site.iterator();
  878.         boolean isEqual = true;
  879.         while (isEqual && siteSortIterator.hasNext()) {
  880.             if (!collectionSortIterator.next().equals(siteSortIterator.next())) {
  881.                 isEqual = false;
  882.             }
  883.         }
  884.         return isEqual;
  885.     }
  886.    
  887.     /**
  888.      * Checks if social network contains zero accounts
  889.      *
  890.      * @return          true or false.
  891.      */
  892.     public boolean isContainZeroAccs(){
  893.         boolean isContainNeededElements = true;
  894.         for(WebElement em : emptySocExpand){
  895.         String socName = em.getText();
  896.         if(!socName.contains("(0) You have not added any"))
  897.             isContainNeededElements = false;
  898.            
  899.             else if(!socName.contains("accounts + add account"))
  900.                     isContainNeededElements = false;
  901.                
  902.         }
  903.        
  904.         return isContainNeededElements;
  905.     }
  906.  
  907.     /**
  908.      * Clicks on each social accounts toggle.
  909.      *
  910.      * @return CompanyPortfolioPage object.
  911.      */
  912.     public CompanyPortfolioPage expandsAllSocialToggles(){
  913.         logger.debug("Expand all social toggles ");
  914.        
  915.         for (WebElement element : socialAccountsList){
  916.             if(element.isDisplayed()){
  917.                 this.clickWithPageReturn(element);         
  918.             }
  919.         }
  920.         return new CompanyPortfolioPage(driver);
  921.     }
  922.  
  923.     /**
  924.      * Clicks on the Add Social Accounts
  925.      * button on the CompanyPortfolioPage.
  926.      *  
  927.      * @return AddSocialAccountsForm object.
  928.      */
  929.     public AddSocialAccountsForm clickOnAddSocialAccountsButton(){
  930.         logger.debug("Click [Add social account] button ");
  931.        
  932.         addSocialAccountsButton.click();
  933.         return new AddSocialAccountsForm(driver);      
  934.     }
  935.    
  936.     /**
  937.      * Clicks on the Invite Your Coworkers.
  938.      * button on the CompanyPortfolioPage.
  939.      *
  940.      * @return InviteYourCoworkersForm object.
  941.      */
  942.     public InviteYourCoworkersForm clickOnInviteYourCoworkersForm(){   
  943.         logger.debug("Click [Invite Coworkers] button ");
  944.        
  945.         inviteYourCoworkersButton.click();
  946.         return new InviteYourCoworkersForm(driver);
  947.     }
  948.    
  949.     /**
  950.      * Clicks on the Clear all filters link
  951.      * on the CompanyPortfolioPage.
  952.      *
  953.      * @return CompanyPortfolioPage object.
  954.      */
  955.     public CompanyPortfolioPage clickOnClearAllFiltersHref(){
  956.         logger.debug("Click [Clear all filters] link ");
  957.        
  958.         clearAllFiltersHref.click();
  959.         return new CompanyPortfolioPage(driver);
  960.     }
  961.    
  962.    
  963.     /**
  964.      * Removes selected Filter by clicking 'x' near it.
  965.      *
  966.      * @param filterName    Name of the filter to remove
  967.      *
  968.      * @return CompanyPortfolioPage object.
  969.      */
  970.     public CompanyPortfolioPage deselectFilter(String filterName){
  971.         WebElement filter = selectedFilters.findElement(By.xpath(".//a[contains(@onclick, '" + filterName + "')]"));
  972.         filter.click();
  973.         return new CompanyPortfolioPage(driver);
  974.     }
  975.    
  976.    
  977.     /**
  978.      * Checks that filter labels are sorted alphabetically.
  979.      *
  980.      * @param labels Filter labels.
  981.      *
  982.      * @return true or false.
  983.      */
  984.     public boolean areFilterLabelsSortedAlphabetically(List<WebElement> labels){
  985.         ArrayList<String> filterSort = new ArrayList<String>();
  986.         ArrayList<String> collectionSort = new ArrayList<String>();
  987.        
  988.         for(WebElement element : labels){
  989.             String name = element.getText().toLowerCase();
  990.             if(!name.equalsIgnoreCase("Select All") && (name.indexOf("assigned") == -1)){
  991.                 filterSort.add(name);
  992.                 collectionSort.add(name);
  993.             }
  994.         }
  995.         Collections.sort(collectionSort);
  996.         boolean isCorrect = this.isSortingOrderCorrect(collectionSort, filterSort);
  997.         return isCorrect;
  998.     }
  999.  
  1000. /* ------------------------------------------- Platforms filter------------------------------------- */
  1001.    
  1002.     /**
  1003.      * Clicks on the Platforms filter.
  1004.      *
  1005.      * @return PlatformsFilter object.
  1006.      */
  1007.     public PlatformsFilter clickOnPlatformsFilter(){
  1008.         logger.debug("Click Platform filter ");
  1009.         try{
  1010.             platformsLink.click();
  1011.         }catch(Exception e){
  1012.             accountFilter = clickAccountFilter();
  1013.             accountFilter.clickPlatformTab();
  1014.         }
  1015.         return new PlatformsFilter(driver);
  1016.     }
  1017.    
  1018.     /**
  1019.      * Clicks "Platforms" filter and then clicks [Cancel] button in the appeared filter form.
  1020.      *
  1021.      * @return  CompanyPortfolioPage object.
  1022.      */
  1023.     public CompanyPortfolioPage clickCancelPlatformsFilter(){
  1024.         logger.debug("Click [Cancel link on the 'Palrform' filter form");
  1025.        
  1026.         platformsLink.click();
  1027.         platformsFilter.clickOnCancelLink();
  1028.         return new CompanyPortfolioPage(driver);       
  1029.     }
  1030.    
  1031.     /**
  1032.      * Clicks "Platforms" filter and then clicks [Show Result] without any checked platform.
  1033.      *
  1034.      * @return  CompanyPortfolioPage object.
  1035.      */
  1036.     public CompanyPortfolioPage clickShowResultPlatformsFilter(){
  1037.         logger.debug("Click [Show Result] button without check checkboxes ");
  1038.        
  1039.         platformsLink.click();
  1040.         platformsFilter.clickOnShowResultsButtonWithoutCheckMark();
  1041.         return new CompanyPortfolioPage(driver);
  1042.     }
  1043.    
  1044.     /**
  1045.      * Clicks "Platforms" filter checks
  1046.      * needed platform and then clicks [Show Result].
  1047.      *
  1048.      * @param platformName              name of the platform
  1049.      *
  1050.      * @return  CompanyPortfolioPage object.
  1051.      */
  1052.     public CompanyPortfolioPage checkPlatformAndShowResult(String platformName){
  1053.         platformsFilter = this.clickOnPlatformsFilter();
  1054.         platformsFilter.checkPlatforms(platformName);
  1055.         return new CompanyPortfolioPage(driver);
  1056.     }
  1057.    
  1058.    
  1059.     /**
  1060.      * Shows result based on the random platform.
  1061.      *
  1062.      * @return  CompanyPortfolioPage object.
  1063.      */
  1064.     public CompanyPortfolioPage showResultBasedOnRandomPlatformFilter(){
  1065.         platformsFilter = this.clickOnPlatformsFilter();
  1066.         platformsFilter.checkRandomPlatform();
  1067.         return new CompanyPortfolioPage(driver);       
  1068.     }
  1069.    
  1070.    
  1071. /* ------------------------------------------- Brands filter-------------------------------------- */  
  1072.  
  1073.     /**
  1074.      * Clicks on the Brands filter.
  1075.      *
  1076.      * @return BrandsFilter object.
  1077.      */
  1078.     public BrandsFilter clickOnBrandsFilter(){
  1079.         logger.debug("Click Brands filter ");
  1080.        
  1081.         brandFormLink.click();
  1082.         return new BrandsFilter(driver);
  1083.     }
  1084.    
  1085.     /**
  1086.      * Clicks [Cancel] link in the "Brand" filter.
  1087.      *
  1088.      * @return  CompanyPortfolioPage filter.
  1089.      */
  1090.     public CompanyPortfolioPage clickCancelBrandsFilter(){
  1091.         logger.debug("Click [Cancel] link on the Brand filter form ");
  1092.        
  1093.         brandFormLink.click();
  1094.         brandsFilter.clickOnCancelLink();
  1095.         return new CompanyPortfolioPage(driver);
  1096.     }
  1097.    
  1098.     /**
  1099.      * Clicks [Show result] link in the "Brand" filter.
  1100.      *
  1101.      * @return  EmployeePortfolioPage filter.
  1102.      */
  1103.     public CompanyPortfolioPage clickOnShowResultBrandsFilter(){
  1104.         logger.debug("Click [Show result] link on Brand filter form ");
  1105.        
  1106.         brandFormLink.click();
  1107.         brandsFilter.clickOnShowResult();
  1108.         return new CompanyPortfolioPage(driver);
  1109.     }
  1110.    
  1111.     /**
  1112.      * Shows result based on the checked specified brand.
  1113.      *
  1114.      * @param brandName Brand name.
  1115.      *
  1116.      * @return  EmployeePortfolioPage object.
  1117.      */
  1118.     public CompanyPortfolioPage showResultsBasedOnSpecifiedBrandFilter(String brandName){
  1119.         brandFormLink.click();
  1120.         brandsFilter.showResultsBasedOnSpecifiedBrand(brandName);
  1121.         return new CompanyPortfolioPage(driver);       
  1122.     }
  1123.    
  1124.     /**
  1125.      * Shows result based on the random brand.
  1126.      *
  1127.      * @return  EmployeePortfolioPage object.
  1128.      */
  1129.     public CompanyPortfolioPage showResultBasedOnRandomBrandFilter(){
  1130.         brandsFilter = this.clickOnBrandsFilter();
  1131.         brandsFilter.showResultBasedOnRandomBrand();
  1132.         return new CompanyPortfolioPage(driver);       
  1133.     }
  1134.    
  1135.     /**
  1136.      * Show result based on the specified competitors brand name.
  1137.      *
  1138.      * @param competitorsName   Competitors name.
  1139.      *
  1140.      * @return  EmployeePortfolioPage object.
  1141.      */
  1142.     public CompanyPortfolioPage showResultBasedOnSpecifiedCompetitorsBrandFilter(String competitorsName){
  1143.         brandFormLink.click();
  1144.         brandsFilter.showResultBasedOnSpecifiedCompetitors(competitorsName);
  1145.         return new CompanyPortfolioPage(driver);
  1146.     }
  1147.    
  1148.     /**
  1149.      * Show result based on the random competitors brand.
  1150.      *
  1151.      * @return  EmployeePortfolioPage object.
  1152.      */
  1153.     public CompanyPortfolioPage showResultBasedOnRandomCompetitorsBrandFilter(){
  1154.         brandsFilter = this.clickOnBrandsFilter();
  1155.         brandsFilter.showResultBasedOnRandomCompetitors();
  1156.         return new CompanyPortfolioPage(driver);
  1157.     }
  1158.    
  1159.  
  1160. /* ------------------------------------------- Owners filter-------------------------------------- */
  1161.    
  1162.     /**
  1163.      * Clicks [Cancel] button.
  1164.      *
  1165.      * @return CompanyPortfolioPage object.
  1166.      */
  1167.     public CompanyPortfolioPage clickCancelOwnersFilter(){
  1168.         logger.debug("Click [Cancel] link on the Owner filter form ");
  1169.        
  1170.         ownersFormLink.click();
  1171.         ownersFilter.clickOnCancelLink();  
  1172.         return new CompanyPortfolioPage(driver);
  1173.     }
  1174.    
  1175.    
  1176.     /**
  1177.      * Clicks Subsidiaries filter link
  1178.      *  
  1179.      * @return OwnersFilter object.
  1180.      */
  1181.     public OwnersFilter clickOwnersLink(){
  1182.         logger.debug("Click [Owner] link ");
  1183.        
  1184.         ownersFormLink.click();
  1185.         return new OwnersFilter(driver);
  1186.     }
  1187.     /**
  1188.      * Shows result without checked owner's checkbox.
  1189.      *
  1190.      * @return CompanyPortfolioPage object.
  1191.      */
  1192.     public CompanyPortfolioPage clickOnShowResultButtonOwnersFilter(){
  1193.         logger.debug("Click [Show Result] button in the Owner filter form ");
  1194.        
  1195.         ownersFormLink.click();
  1196.         ownersFilter.clickOnShowResultButton();
  1197.         return new CompanyPortfolioPage(driver);       
  1198.     }
  1199.  
  1200.     /**
  1201.      * Shows result based on the additional "Unassigned owner" filter.
  1202.      *
  1203.      * @return CompanyPortfolioPage object.
  1204.      */
  1205.     public CompanyPortfolioPage checkOwnerUnassignedChecBoxOwnersFilter(){
  1206.         logger.debug("Check [Unassigned checkbox on the [Owners] filter form ");
  1207.        
  1208.         ownersFormLink.click();
  1209.         ownersFilter.checkOwnerUnassignedChecBox();
  1210.         return new CompanyPortfolioPage(driver);
  1211.     }
  1212.    
  1213.     /**
  1214.      * Shows result based on the specified checked owner.
  1215.      *
  1216.      * @param ownerName Owner Name.
  1217.      *
  1218.      * @return  CompanyPortfolioPage object.
  1219.      */
  1220.     public CompanyPortfolioPage resultBasedOnCheckedOwner(String ownerName){       
  1221.         ownersFormLink.click();
  1222.         ownersFilter.resultBasedOnCheckedOwner(ownerName);
  1223.         return new CompanyPortfolioPage(driver);
  1224.     }
  1225.    
  1226.     /**
  1227.      * Shows result based on the random checked owner.
  1228.      *
  1229.      * @return CompanyPortfolioPage object.
  1230.      */
  1231.     public CompanyPortfolioPage resultBasedOnRandomOwner(){
  1232.         ownersFilter = this.clickOwnersLink();
  1233.         ownersFilter.resultBasedOnRandomOwner();
  1234.         return new CompanyPortfolioPage(driver);       
  1235.     }
  1236.    
  1237.    
  1238. /* ------------------------------------------- Regions filter-------------------------------------- */ 
  1239.    
  1240.     /**
  1241.      * Clicks [Cancel] button.
  1242.      *
  1243.      * @return  CompanyPortfolioPage object.
  1244.      */
  1245.     public CompanyPortfolioPage clickCancelButtonRegionFilter(){
  1246.         logger.debug("Click [Cancel] ");
  1247.        
  1248.         regionsFormLink.click();
  1249.         regionsFilter.clickOnCancelLink();
  1250.         return new CompanyPortfolioPage(driver);
  1251.     }
  1252.    
  1253.     /**
  1254.      * Clicks Region filter's link.
  1255.      *
  1256.      * @return Regions Filter Form.
  1257.      */
  1258.     public RegionsFilter clickRegionsFilter(){
  1259.         logger.debug("Click Regions filter");
  1260.        
  1261.         demographicsFilerLink.click();
  1262.         regionsFormLink.click();
  1263.         return new RegionsFilter(driver);
  1264.     }
  1265.    
  1266.     /**
  1267.      * Shows result without checked checkbox.
  1268.      *
  1269.      * @return  CompanyPortfolioPage object.
  1270.      */
  1271.     public CompanyPortfolioPage showResultWithoutRestriction(){
  1272.         regionsFormLink.click();
  1273.         regionsFilter.clickOnShowResultButton();
  1274.         return new CompanyPortfolioPage(driver);
  1275.     }
  1276.    
  1277.     /**
  1278.      * Shows result based on the checked region.
  1279.      *
  1280.      * @param regionName    Region name.
  1281.      *
  1282.      * @return  CompanyPortfolioPage object.
  1283.      */
  1284.     public CompanyPortfolioPage resultBasedOnCheckedGroup(String regionName){
  1285.         regionsFormLink.click();
  1286.         regionsFilter.checkRegionGroup(regionName);
  1287.         return new CompanyPortfolioPage(driver);
  1288.     }
  1289.    
  1290.     /**
  1291.      * Shows result based on the checked country in the desired region.
  1292.      *
  1293.      * @param regionName    Region name.
  1294.      * @param countryName   Country name.
  1295.      *
  1296.      * @return  CompanyPortfolioPage object.
  1297.      */
  1298.     public CompanyPortfolioPage resultBasedOnCheckedCountry(String regionName, String countryName){
  1299.         regionsFormLink.click();
  1300.         regionsFilter.showReultBasedOnNeededCountry(regionName, countryName);
  1301.         return new CompanyPortfolioPage(driver);
  1302.     }
  1303.    
  1304.     /**
  1305.      * Shows result based on the random country.
  1306.      *
  1307.      * @return CompanyPortfolioPage object.
  1308.      */
  1309.     public CompanyPortfolioPage resultBasedOnRandomCountry(){
  1310.         regionsFilter = this.clickRegionsFilter();
  1311.         regionsFilter.resultBasedOnRandomCountry();
  1312.         return new CompanyPortfolioPage(driver);       
  1313.     }
  1314.    
  1315.    
  1316. /* ------------------------------------------- Subsidiaries filter-------------------------------------- */
  1317.    
  1318.     /**
  1319.      * Clicks [Cancel] buton.
  1320.      *
  1321.      * @return  CompanyPortfolioPage object.
  1322.      */
  1323.     public CompanyPortfolioPage clickCancelButton(){
  1324.         logger.debug("Click [Cancel] button ");
  1325.        
  1326.         subsidiariesFormLink.click();
  1327.         subsidiariesFilter.clickOnCancelLink();
  1328.         return new CompanyPortfolioPage(driver);
  1329.     }
  1330.     /**
  1331.      *  clicks Subsidiaries filter link.
  1332.      *  
  1333.      * @return SubsidiariesFilter object
  1334.      */
  1335.     public SubsidiariesFilter clickSubisiriesLink(){
  1336.         logger.debug("Click Subsidiary filter ");
  1337.        
  1338.         subsidiariesFormLink.click();
  1339.         return new SubsidiariesFilter(driver);
  1340.     }
  1341.     /**
  1342.      * Shows result without checked checkbox.
  1343.      *
  1344.      * @return  CompanyPortfolioPage object.
  1345.      */
  1346.     public CompanyPortfolioPage showResultWithoutCheckedRestriction(){
  1347.         subsidiariesFormLink.click();
  1348.         subsidiariesFilter.clickOnShowResultButton();
  1349.         return new CompanyPortfolioPage(driver);
  1350.     }
  1351.    
  1352.     /**
  1353.      * Shows result based on the checked "Subsidiaries Unassigned" checkbox.
  1354.      *
  1355.      * @return  CompanyPortfolioPage object.
  1356.      */
  1357.     public CompanyPortfolioPage checkSubsidiariesUnassignedCheckbox(){
  1358.         logger.debug("Check unassigned checkbox ");
  1359.        
  1360.         subsidiariesFilter = clickSubisiriesLink();
  1361.         subsidiariesFilter.checkSubsidiariesUnassignedCheckBox();
  1362.         return new CompanyPortfolioPage(driver);
  1363.     }
  1364.    
  1365.     /**
  1366.      * Shows result based on the checked desired subsidiaries restriction.
  1367.      *
  1368.      * @param subsidiariesName  Subsidiaries name.
  1369.      *
  1370.      * @return  CompanyPortfolioPage object.
  1371.      */
  1372.     public CompanyPortfolioPage resultBasedOnSubsidiariesCheckbox(String subsidiariesName){
  1373.         this.clickSubisiriesLink();
  1374.         subsidiariesFilter.checkSubsidiariesCheckbox(subsidiariesName);
  1375.         return new CompanyPortfolioPage(driver);
  1376.     }
  1377.    
  1378.    
  1379.     /**
  1380.      * Shows result based on the random subsidiary.
  1381.      *
  1382.      * @return CompanyPortfolioPage object.
  1383.      */
  1384.     public CompanyPortfolioPage resultBasedOnRandomSubsidiary(){
  1385.         subsidiariesFilter = this.clickSubisiriesLink();
  1386.         subsidiariesFilter.checkSubsidiaries();
  1387.         return new CompanyPortfolioPage(driver);       
  1388.     }
  1389.    
  1390.        
  1391. /* ------------------------------------------- Departments filter-------------------------------------- */
  1392.  
  1393.     /**
  1394.      * Clicks [Cancel] button.
  1395.      *
  1396.      * @return  CompanyPortfolioPage object.
  1397.      */
  1398.     public CompanyPortfolioPage clickCancelButtonDepartmentsFilter(){
  1399.         logger.debug("Click [Cancel] link in the [Department] filter form");
  1400.        
  1401.         departmentsFormLink.click();
  1402.         departmentsFilter.clickOnCancelLink();
  1403.         return new CompanyPortfolioPage(driver);
  1404.     }
  1405.    
  1406.     /**
  1407.      * Shows result without checked checkbox.
  1408.      *
  1409.      * @return  CompanyPortfolioPage object.
  1410.      */
  1411.     public CompanyPortfolioPage showResultWithoutAnyRestriction(){
  1412.         departmentsFormLink.click();
  1413.         departmentsFilter.clickOnShowResultButton();
  1414.         return new CompanyPortfolioPage(driver);
  1415.     }
  1416.    
  1417.     /**
  1418.      * Shows result based on the checked "Department Unassigned" checkbox.
  1419.      *
  1420.      * @return  CompanyPortfolioPage object.
  1421.      */
  1422.     public CompanyPortfolioPage resultBasedOnUnassignedCheckbox(){
  1423.         departmentsFormLink.click();
  1424.         departmentsFilter.checkDepartmentUnassignedCheckBox();
  1425.         return new CompanyPortfolioPage(driver);
  1426.     }
  1427.    
  1428.     /**
  1429.      * clicks department filter's link
  1430.      *
  1431.      * @return Regions Filter Form
  1432.      */
  1433.  
  1434.     public DepartmentsFilter clickDepartmentsFilter(){
  1435.         logger.debug("Click Department filter");
  1436.        
  1437.         departmentsFormLink.click();
  1438.         return new DepartmentsFilter(driver);
  1439.     }
  1440.  
  1441.    
  1442.  
  1443.     /**
  1444.      * Shows result based on the checked specified department.
  1445.      *
  1446.      * @param departmentName    Department name.
  1447.      *
  1448.      * @return  CompanyPortfolioPage object.
  1449.      */
  1450.     public CompanyPortfolioPage showResultBasedOnSpecifiedDepartment(String departmentName){
  1451.         departmentsFormLink.click();
  1452.         departmentsFilter.showResultBasedOnCheckedSpecifiedDepartment(departmentName);
  1453.         return new CompanyPortfolioPage(driver);
  1454.     }
  1455.    
  1456.    
  1457.     /**
  1458.      * Shows result based on the random department.
  1459.      *
  1460.      * @return CompanyPortfolioPage object.
  1461.      */
  1462.     public CompanyPortfolioPage resultBasedOnRandomDepartment(){
  1463.         departmentsFilter = this.clickDepartmentsFilter();
  1464.         departmentsFilter.checkRandomDepartment();
  1465.         return new CompanyPortfolioPage(driver);       
  1466.     }
  1467.    
  1468. /*----------------------------------------------------------------------------------------------------- */
  1469.    
  1470.    
  1471.     /**
  1472.      * Clicks on the Edit Account link for the
  1473.      * specific Social Account.
  1474.      *
  1475.      * @param accountUserName.
  1476.      *
  1477.      * @return  editSocialAccountsForm object.
  1478.      */
  1479.    
  1480.     public AddSocialAccountsForm clickOnEditAccountLink(String accountUserName) {
  1481.         logger.debug("Click [Edit Account] link with following value: <br>" +
  1482.                 "accountUserName - social account name ");
  1483.        
  1484.         WebElement socialProfileEditAccountLink;
  1485.         this.findAndCheckNeededSocialProfile(accountUserName);
  1486.         this.mouseOverAccountSettings();
  1487.         socialProfileEditAccountLink = socialProfileForm.findElement(By
  1488.                 .xpath(".//tbody/tr/td/div/h2[contains(.,'" + accountUserName
  1489.                         + "')]/../..//a[contains(.,'Edit Account Info')]"));
  1490.         common.jsClick(socialProfileEditAccountLink);
  1491.         return new AddSocialAccountsForm(driver);
  1492.     }
  1493.    
  1494.    
  1495.     /**
  1496.      * Clicks on Settings.
  1497.      *
  1498.      * @return CompanyPortfolioPage object.
  1499.      */
  1500.     public CompanyPortfolioPage clickSettings(){
  1501.         logger.debug("Click settings ");
  1502.        
  1503.         settingsButton.click();
  1504.         return new CompanyPortfolioPage(driver);
  1505.     }
  1506.    
  1507.    
  1508.     /**
  1509.      * Clicks on Export Result link.
  1510.      *
  1511.      * @return CompanyPortfolioPage object.
  1512.      */
  1513.     public CompanyPortfolioPage clickExportResultsLink(){
  1514.         exportResultsLink.click();
  1515.         return new CompanyPortfolioPage(driver);
  1516.     }
  1517.    
  1518.    
  1519.     /**
  1520.      * Exports accounts to xls file.
  1521.      *
  1522.      * @return CompanyPortfolioPage object.
  1523.      */
  1524.     public CompanyPortfolioPage exportResults(){       
  1525.         String filespath = common.getProjectRoot() + "test-data" + "\\files";
  1526.         System.out.println(filespath);
  1527.         common.deleteFile(filespath + "\\accounts.xls");
  1528.         this.clickSettings();
  1529.         this.clickExportResultsLink();
  1530.         return new CompanyPortfolioPage(driver);
  1531.     }
  1532.    
  1533.    
  1534.     /**
  1535.      * Clicks on Import Accounts link.
  1536.      *
  1537.      * @return CompanyPortfolioPage object.
  1538.      */
  1539.     public ImportSocialAccountsForm clickImportAccountsLink(){
  1540.         logger.debug("Click [Import Accounts] link ");
  1541.        
  1542.         importAccountsLink.click();
  1543.         return new ImportSocialAccountsForm(driver);
  1544.     }
  1545.    
  1546.    
  1547.     /**
  1548.      * Imports accounts from file.
  1549.      *
  1550.      * @param filePath  Absolute path to file with file name.
  1551.      *
  1552.      * @return  CompanyPortfolioPage object.
  1553.      */
  1554.     public CompanyPortfolioPage importAccounts(String filePath){
  1555.         this.clickSettings();
  1556.         importSocialAccountsForm = this.clickImportAccountsLink();
  1557.         importSocialAccountsForm.importFile(filePath);
  1558.         return new CompanyPortfolioPage(driver);
  1559.     }
  1560.    
  1561.    
  1562.     /**
  1563.      * Creates file with accounts and imports one
  1564.      *
  1565.      * @return CompanyPortfolioPage object.
  1566.      *
  1567.      */
  1568.     public CompanyPortfolioPage createFileAndImport(int numOfAccounts, String network) {
  1569.         this.clickSettings();
  1570.         importSocialAccountsForm = this.clickImportAccountsLink();
  1571.         try {
  1572.             importSocialAccountsForm.importFileWithRandomAccounts(numOfAccounts, network, "company");
  1573.         } catch (IOException e) {
  1574.         }
  1575.         return new CompanyPortfolioPage(driver);   
  1576.     }
  1577.    
  1578.    
  1579.     /**
  1580.      * Clicks on the Edit Account link for the
  1581.      * specific Social Account.
  1582.      *
  1583.      * @param accountUserName.
  1584.      *
  1585.      * @return  editSocialAccountsForm object.
  1586.      */
  1587.     public AddSocialAccountsForm clickOnEditLinkInAccountDetails(String accountUserName) {
  1588.         logger.debug("Click [Edit Account] link in account details for specified user: <br>" +
  1589.                         "user name - " + accountUserName);
  1590.  
  1591.         WebElement socialProfileEditAccountLink;
  1592.         socialProfileEditAccountLink = socialProfileForm.findElement(By
  1593.                 .xpath(".//li[contains(.,'" + accountUserName
  1594.                         + "')]/../..//a[contains(.,'Edit Account')]"));
  1595.         socialProfileEditAccountLink.click();
  1596.         return new AddSocialAccountsForm(driver);
  1597.     }
  1598.    
  1599.    
  1600.     /**
  1601.      * Clicks on the Message These Users link for the
  1602.      * specific Social Account.
  1603.      *
  1604.      * @param accountUserName
  1605.      *
  1606.      * @return emailAccountOwnersForm object.
  1607.      */
  1608.     public EmailAccountOwnersForm clickOnMessageTheseUsersLink(String accountUserName) {
  1609.         logger.debug("Click [Message this user] link");
  1610.        
  1611.         WebElement socialProfileEditAccountLink;
  1612.         this.findAndCheckNeededSocialProfile(accountUserName);
  1613.         socialProfileEditAccountLink = socialProfileForm.findElement(By
  1614.                 .xpath(".//li[contains(.,'" + accountUserName
  1615.                         + "')]/../..//a[contains(.,'Message these users')]"));
  1616.         socialProfileEditAccountLink.click();
  1617.         return new EmailAccountOwnersForm(driver);
  1618.     }
  1619.  
  1620.    
  1621.     /**
  1622.      * Clicks on the Assign Account Owner link for the      
  1623.      * specific Accounts user name.
  1624.      *
  1625.      * @param AccountUserName   Accounts user name.
  1626.      *
  1627.      * @return  AccountOwnerInformationForm object.
  1628.      */
  1629.     public AccountOwnerInformationForm clickOnAssignAcctOwnerLink(
  1630.             String AccountUserName) {
  1631.         logger.debug("Click [Assign account] link ");
  1632.        
  1633.         WebElement accountName, assignAccountOwnerLink;
  1634.         accountName = common.findElementInList(accountUserList,
  1635.                 AccountUserName);
  1636.         common.mouseOver(accountName);
  1637.         assignAccountOwnerLink = accountName.findElement(
  1638.                 By.xpath(xpathAssignAccountLink));
  1639.         assignAccountOwnerLink.click();                                    
  1640.         return new AccountOwnerInformationForm(driver);
  1641.     }
  1642.  
  1643.    /**
  1644.     * Clicks on the [+add account] link.
  1645.     *
  1646.     * @param socialAccount  Social Account Name.
  1647.     *
  1648.     * @return   AddSocialAccountsForm object.
  1649.     */
  1650.     public AddSocialAccountsForm clickOnAddAccountLink(String socialAccountType) {
  1651.         logger.debug("Click [Add Account] link");
  1652.        
  1653. //      WebElement socialAccountName, addAccountLink;
  1654. //      socialAccountName = common.findElementInList(socialAccountsList,
  1655. //              socialAccount);
  1656. //      common.mouseOver(socialAccountName);
  1657. //      addAccountLink = socialAccountName.findElement(
  1658. //              By.xpath("//a[contains(text(), '+ add account')]"));
  1659. //      addAccountLink.click();      
  1660.         WebElement addAccountLink;
  1661.         String accountType = socialAccountType.toLowerCase();
  1662.         addAccountLink = socialProfileForm.findElement(By.xpath("//a[contains(@onclick,'" + accountType + "')]"));
  1663.         addAccountLink.click();
  1664.         return new AddSocialAccountsForm(driver);
  1665.    }
  1666.    
  1667.     /**
  1668.      * Opens External Social Account Url.
  1669.      *
  1670.      * @param accountUserName   Account User Name
  1671.      *
  1672.      * @version 2.
  1673.      */
  1674.     public void openExternalAccountUrl(String accountUserName) {       
  1675.         WebElement socialProfileExternalUrl;       
  1676.         socialProfileExternalUrl = socialProfileForm.findElement(By.xpath(xpathExternalAccountUrl));
  1677.         socialProfileExternalUrl.click();
  1678.     }  
  1679.    
  1680.    
  1681.     /**
  1682.       * checks if all socialNetworkExpands displayed needed count of accounts.
  1683.        *
  1684.        * @param countValid   needed count of accounts.
  1685.        *
  1686.        * @return true or false.
  1687.        */
  1688.     public boolean isCountValidInExpands(int countValid) {
  1689.  
  1690.         boolean validExpand = true;
  1691.         for (WebElement each : listofSocials) {
  1692.             this.clickWithPageReturn(each);
  1693.             List<WebElement> accounts = each.findElements(By.xpath(".//..//span[contains(@class,'withoutDisplayName')]"));
  1694.             int listSize = accounts.size();
  1695.             if (listSize > countValid) {
  1696.                 validExpand = false;
  1697.             }
  1698.             this.clickWithPageReturn(each);
  1699.         }
  1700.         return validExpand;
  1701.     }
  1702.    
  1703.    
  1704.     /**
  1705.      * Checks is filter label displayed.
  1706.      *
  1707.      * @param filterName    Filter name.
  1708.      *
  1709.      * @return true or false.
  1710.      */
  1711.     public boolean isSelectedFilterLabelDisplayed(String filterName){
  1712. //      List <WebElement> listOfSelectedFilters;
  1713. //      listOfSelectedFilters = selectedFilters.findElements(By.xpath(xpathListOfSelectedFilters));
  1714.         WebElement filter = common.findElementInList(listOfSelectedFilters, filterName);
  1715.         boolean isDisplayed = common.isElementDisplayed(filter);
  1716.         return isDisplayed;
  1717.     }
  1718.    
  1719.    
  1720.      /**
  1721.        * Checks if cssValue overflow is hidden, if it's hidden then long account
  1722.        *  names are half hidden.
  1723.        *
  1724.        *
  1725.        * @return true or false.
  1726.        */
  1727.      public boolean isNotWrapped(){
  1728.          boolean isNotWrapp = true;
  1729.          for (WebElement em :listOfNames){           
  1730.                 String scrollWidth = em.getCssValue("overflow");
  1731.                 if(!scrollWidth.equals("hidden")){
  1732.                     isNotWrapp = false;
  1733.                 }
  1734.                
  1735.          }
  1736.             return isNotWrapp;
  1737.            
  1738.      }
  1739.      /**
  1740.        * checks if all account audience contains comma if it more than 999.
  1741.        *
  1742.        *
  1743.        * @return true or false.
  1744.        */
  1745.      public boolean isContainComma(){
  1746.          boolean isWithComma = true;
  1747.          for (WebElement em : listofAudience){
  1748.          String textAudience = em.getText();
  1749.                 if(textAudience.length()>3 && !textAudience.contains("Pending")){
  1750.                     if(!textAudience.contains(",")){
  1751.                       isWithComma = false;
  1752.                       return isWithComma;
  1753.                 }
  1754.             }
  1755.          }
  1756.          return isWithComma;
  1757.      }   
  1758.    
  1759.      
  1760.      /**
  1761.       * Checks count of displayed accounts in social network.
  1762.       *
  1763.       * @param network  Social network.
  1764.       * @param num  Needed number of accounts to display.
  1765.       *
  1766.       * @return true or false.
  1767.       */
  1768.      public boolean isAccountsOnPageCountValid(String network, int num){
  1769.          WebElement networkIndex = cpForm.findElement(By.id(network + "_index"));
  1770.          String index = networkIndex.getText();
  1771.          int indexNumber = Integer.parseInt(index);
  1772.          if(indexNumber == num && num == accountlist.size()){
  1773.              return true;
  1774.          }
  1775.          else return false;
  1776.      }
  1777.      
  1778.      
  1779.      /**  If social accounts more than 80 in social network headers, then all expands should be closed,
  1780.       * if more than 80 then should be collapsed.
  1781.       *
  1782.       * @return      true or false.
  1783.       */
  1784.      public boolean isSocialNetworksExpandedorNot(){
  1785.             int count = 0;
  1786.             boolean isExpanded = false;
  1787.             for(WebElement each : listofSoc){    //for Each Social network on the page;
  1788.                 String headertext = each.getText();
  1789.             int accountsCount = Integer.parseInt(headertext.substring(  
  1790.                 headertext.indexOf("(") + 1, headertext.indexOf(")")));  //we take number of accounts from each Social network Header;
  1791.                 count = count+accountsCount;       
  1792.             }
  1793.             if(count < 80){
  1794.                 isExpanded = true;
  1795.             }
  1796.             return isExpanded;
  1797.         }
  1798.        
  1799.          
  1800.      /**
  1801.       * Clicks on random account name.
  1802.       *
  1803.       * @return account name.
  1804.       */
  1805.      public String clickRandomName(){
  1806.          logger.debug("Click random account name ");
  1807.          
  1808.         WebElement randomAccount;
  1809.         randomAccount = common.randomElementFromTheList(accountUserList);
  1810.         this.clickWithPageReturn(randomAccount);
  1811.         return randomAccount.getText();
  1812.      }
  1813.      
  1814.      /**
  1815.       * Gets random account name.
  1816.       *
  1817.       * @return account name.
  1818.       */
  1819.      public String getRandomName(){
  1820.         String[] result;
  1821.         String name = common.randomElementFromTheList(accountUserList).getText();
  1822.         if (name.contains("@"))
  1823.         {
  1824.             result = name.split(" ");
  1825.             name = result[0];
  1826.         }
  1827.         return name;
  1828.      }
  1829.      
  1830.  
  1831.      /**
  1832.       * Clicks on random account name with no ajax wait.
  1833.       *
  1834.       * @return account name.
  1835.       */
  1836.      public String clickRandomNameNoAjax(){
  1837.          logger.debug("Click random account name with no ajax wait ");
  1838.          
  1839.             WebElement randomAccount;
  1840.             randomAccount = common.randomElementFromTheList(accountUserList);
  1841.             randomAccount.click();
  1842.             return randomAccount.getText();
  1843.         }
  1844.  
  1845.  
  1846.     /**
  1847.      * Clicks Random account assign link.
  1848.      *
  1849.      * @return  true or false.
  1850.      */
  1851.     public AccountOwnerInformationForm clickRandomAssignAcct(){
  1852.         logger.debug("Click random [assign] link ");
  1853.        
  1854.          WebElement randomUser;
  1855.             randomUser = listofAssigns.get((int)(Math.random()*100)%listofAssigns.size());
  1856.             randomUser.click();
  1857.             return new AccountOwnerInformationForm(driver);
  1858.     }
  1859.    
  1860.    
  1861.     /**
  1862.      * Gets account names.
  1863.      *
  1864.      * @return List of names.
  1865.      */
  1866.     public ArrayList<String> getAccountNames(){
  1867.         ArrayList<String> accountsName = new ArrayList<String>();
  1868.         accountsName = common.getText(accountlist);
  1869.         return accountsName;
  1870.     }
  1871.    
  1872.    
  1873.     /**
  1874.      * Compares number of accounts in list with number of accounts written in
  1875.      * SocialNetworkHeader.
  1876.      *
  1877.      * @return true of false.
  1878.      **/
  1879.     public boolean isNumberOfAccountsCorrect() {
  1880.         boolean validExpand = true;
  1881.         if(common.isElementDisplayed(leftArrow)){
  1882.             return validExpand;
  1883.         }
  1884.         for (WebElement each : socialAccount) {
  1885.             if(!common.isElementDisplayed(userColumnSpan)){
  1886.                 this.clickWithPageReturn(each);
  1887.             }
  1888.             try{
  1889.                 WebElement showMore = each.findElement(By.xpath(".//..//td[@colspan]"));
  1890.                 while(common.isElementDisplayed(showMore)){
  1891.                     this.clickWithPageReturn(showMore);
  1892.                 }
  1893.             }catch(NoSuchElementException e){}
  1894.            
  1895.             List<WebElement> accounts = each.findElements(By.xpath(".//..//span[contains(@class,'withoutDisplayName')]|.//..//i[contains(@class,'display_nameEllipsis')]"));
  1896.             int listSize = accounts.size();
  1897.             String displayedCount = each.getText();
  1898.             int displayedCountNumber = Integer.parseInt(displayedCount.substring(
  1899.                     displayedCount.lastIndexOf("(") + 1, displayedCount.lastIndexOf(")")));
  1900.             if (listSize != displayedCountNumber) {
  1901.                 validExpand = false;
  1902.             }
  1903.             each.click();
  1904.         }
  1905.         return validExpand;
  1906.     }
  1907.    
  1908.     /**
  1909.      * Clicks specified webelement and returns Company Portfolio Page object.
  1910.      *
  1911.      * @param elementToClick                    WebElement to click.       
  1912.      *
  1913.      * @return                                  CompanyPortfolioPage.
  1914.      */
  1915.     public CompanyPortfolioPage clickWithPageReturn(WebElement elementToClick){
  1916.         elementToClick.click();
  1917.         return new CompanyPortfolioPage(driver);
  1918.     }
  1919.    
  1920.     /**
  1921.      * Checks aligning of the elements (such as account name, user name, percent) in one random row.
  1922.      *
  1923.      * @return true or false.
  1924.      */
  1925.     public boolean areElementsVerticallyAlignedInRandomRow(){
  1926.        
  1927.         boolean isAligned = true;
  1928.        
  1929.         WebElement row = common.randomElementFromTheList(allListPage);
  1930.         int rowHeight = row.getSize().getHeight();
  1931.         int rowY = row.getLocation().getY();
  1932.         int rowBaseline = rowY + rowHeight/2;
  1933.  
  1934.         WebElement accountName = row.findElement(By.xpath(".//span[contains(@class,'withoutDisplayName')]|.//i[contains(@class,'display_nameEllipsis')]"));
  1935.         int accountHeight = accountName.getSize().getHeight();
  1936.         int accountY = accountName.getLocation().getY();
  1937.         int accountBaseline = accountY + accountHeight/2;
  1938.         if(Math.abs(rowBaseline - accountBaseline)>3){
  1939.             isAligned = false;
  1940.         }
  1941.        
  1942.         WebElement userName = row.findElement(By.xpath(".//td[@class='user']/a|.//div[@class='ellipsis']"));
  1943.         int userHeight = userName.getSize().getHeight();
  1944.         int userY = userName.getLocation().getY();
  1945.         int userBaseline = userY + userHeight/2;
  1946.         if(Math.abs(rowBaseline - userBaseline)>3){
  1947.             isAligned = false;
  1948.         }
  1949.  
  1950.         WebElement signal = row.findElement(By.xpath(".//td[@class='signal']/*"));
  1951.         int signalHeight = signal.getSize().getHeight();
  1952.         int signalY = signal.getLocation().getY();
  1953.         int signalBaseline = signalY + signalHeight/2;
  1954.         if(Math.abs(rowBaseline - signalBaseline)>3){
  1955.             isAligned = false;
  1956.         }
  1957.        
  1958.         WebElement circle = row.findElement(By.xpath(".//td[@id='complete']/div"));
  1959.         int circleHeight = circle.getSize().getHeight();
  1960.         int circleY = circle.getLocation().getY();
  1961.         int circleBaseline = circleY + circleHeight/2;
  1962.         if(Math.abs(rowBaseline - circleBaseline)>3){
  1963.             isAligned = false;
  1964.         }
  1965.        
  1966.         WebElement percentComplete = row.findElement(By.xpath(".//*[@id='complete']/p[1]"));
  1967.         int percentHeight = percentComplete.getSize().getHeight();
  1968.         int percentY = percentComplete.getLocation().getY();
  1969.         int percentBaseline = percentY + percentHeight/2;
  1970.         if(Math.abs(rowBaseline - percentBaseline)>3){
  1971.             isAligned = false;
  1972.         }
  1973.        
  1974.         int moreBaseline = rowBaseline;
  1975.         int moreInfoBaseline = rowBaseline;
  1976.         int pendingBaseline = rowBaseline;
  1977.        
  1978.         try{
  1979.             WebElement more = row.findElement(By.xpath(".//div[contains(text(), 'more')]"));
  1980.             int moreHeight = more.getSize().getHeight();
  1981.             int moreY = more.getLocation().getY();
  1982.             moreBaseline = moreY + moreHeight/2;
  1983.             if(Math.abs(rowBaseline - moreBaseline)>1){
  1984.                 isAligned = false;
  1985.             }
  1986.            
  1987.             WebElement moreInfo = row.findElement(By.xpath(".//td[@class='moreInfo']/span"));
  1988.             int moreInfoHeight = moreInfo.getSize().getHeight();
  1989.             int moreInfoY = moreInfo.getLocation().getY();
  1990.             moreInfoBaseline = moreInfoY + moreInfoHeight/2;
  1991.             if(Math.abs(rowBaseline - moreInfoBaseline)>1){
  1992.                 isAligned = false;
  1993.             }
  1994.            
  1995.             WebElement pending = row.findElement(By.xpath(".//td[@class='Audience']/*"));
  1996.             int pendingHeight = pending.getSize().getHeight();
  1997.             int pendingY = pending.getLocation().getY();
  1998.             pendingBaseline = pendingY + pendingHeight/2;
  1999.             if(Math.abs(rowBaseline - pendingBaseline)>1){
  2000.                 isAligned = false;
  2001.             }
  2002.         }catch(NoSuchElementException e){};
  2003.         return isAligned;
  2004.     }
  2005.    
  2006.    
  2007.     /**
  2008.      * Mouses over random 'Percent Complete' cell.
  2009.      *
  2010.      * @return appeared link 'Edit Account'.
  2011.      */
  2012.     public WebElement mouseOverRandomPercentComplete(){
  2013.         boolean isDisplayed = false;
  2014.         int counter = 0;
  2015.         WebElement editLink = null;
  2016.         do{
  2017.             try{
  2018.                
  2019.            
  2020.             WebElement randomRow = common.randomElementFromTheList(allListPage);
  2021.             String jQuery = "jQuery('";
  2022.             String mouseOver = "').mouseover();";
  2023.             JavascriptExecutor js = (JavascriptExecutor) driver;
  2024.             js.executeScript(jQuery + cssAccountEditLink + mouseOver);
  2025.             //common.mouseOverJQuery(cssAccountEditLink);
  2026.            
  2027.             editLink = randomRow.findElement(By.xpath(".//td/p/a"));
  2028.             isDisplayed = editLink.isDisplayed();
  2029.             counter ++;
  2030.                 if(isDisplayed){
  2031.                     editLink.click();  
  2032.                 }          
  2033.             }
  2034.             catch(Exception e){
  2035.            
  2036.             }
  2037.         }
  2038.         while(!isDisplayed && counter < 50);
  2039.    
  2040.         return editLink;
  2041.     }
  2042.    
  2043.     /**
  2044.      * Checks if the Company Portfolio Page is Displayed
  2045.      *
  2046.      * @return  isDisplayed or not.
  2047.      */
  2048.     public boolean isCompanyPortfolioPageDisplayed(){
  2049.         boolean isDisplayed;
  2050.         isDisplayed = common.isElementDisplayed(searchField);
  2051.         return isDisplayed;
  2052.     }
  2053.    
  2054.     /**
  2055.      * Checks if the accounts exists on the page.
  2056.      *
  2057.      * @param name                  name of account .
  2058.      *
  2059.      * @return                      true or false.
  2060.      *
  2061.      */
  2062.     public boolean isAccountExists(String name){
  2063.         return common.isAccountExists(name);
  2064.     }
  2065.    
  2066.     /**
  2067.      * Checks if the audience list is sorted by audience.
  2068.      *
  2069.      * @return                      true or false.
  2070.      */
  2071.     public boolean isSortedByAudience(){
  2072.         boolean isSorted = common.isSortedByAudience(audienceList);
  2073.         return isSorted;
  2074.     }
  2075.    
  2076.     /**
  2077.      * Checks if the accounts are sorted alphabetically .
  2078.      *
  2079.      * @return                      true or false.
  2080.      */
  2081.     public boolean isSortedByAlphabet(){
  2082.         boolean isSorted = common.isSortedByAlphabets(accountlist);
  2083.         return isSorted;
  2084.     }
  2085.    
  2086.     /**
  2087.      * Clicks on the audience column.
  2088.      *
  2089.      * @return CompanyPortfolioPage object.
  2090.      */
  2091.     public CompanyPortfolioPage clickAudienceColumn(){
  2092.         logger.debug("Click Audience column ");
  2093.        
  2094.         common.clickVisibleElementsinList(columnAudience);
  2095.         return new CompanyPortfolioPage(driver);
  2096.     }
  2097.    
  2098.     /**
  2099.      * Checks if the CoWorkers button is displayed or not.
  2100.      *
  2101.      * @return                      true or false.
  2102.      */
  2103.     public boolean isCoWorkersButtonAndTextDisplayed(){
  2104.         boolean isDisplayed, textAndButtonDisplayed = false;
  2105.         String workersText = inviteYourCoworkersButton.getText();
  2106.         isDisplayed = common.isElementDisplayed(inviteYourCoworkersButton);
  2107.         if(workersText.equals("Invite Your Coworkers") && isDisplayed ){
  2108.             textAndButtonDisplayed = true;         
  2109.         }
  2110.         return textAndButtonDisplayed;
  2111.     }
  2112.    
  2113.     /**
  2114.      * Checks if the  Owner span is Correct.
  2115.      *
  2116.      * @return                      true or false.
  2117.      */
  2118.     public boolean isOwnerSpanIsCorrect(){
  2119.         String text;
  2120.         boolean isCorrect = false;
  2121.         boolean isDisplayed;
  2122.         isDisplayed = common.isElementDisplayed(ownersSpan);
  2123.         text = ownersSpan.getText();
  2124.         if(text.equals("Owners") && isDisplayed){
  2125.             isCorrect = true;
  2126.         }
  2127.         return isCorrect;
  2128.     }
  2129.    
  2130.     /**
  2131.      * Checks if the Import/Export window is displayed.
  2132.      *
  2133.      * @return                      true or false.
  2134.      */
  2135.     public boolean isImportExportDisplayed(){
  2136.         boolean isDisplayed;
  2137.         isDisplayed = common.isElementDisplayed(importExportWindow);
  2138.         return isDisplayed;
  2139.     }
  2140.    
  2141.     /**
  2142.      * Clicks on the drop down menu
  2143.      *
  2144.      * @return CompanyPortfolioPage object.
  2145.      */
  2146.     public CompanyPortfolioPage clickDropDownMenu(){
  2147.         logger.debug("Click Drop down menu ");
  2148.        
  2149.         platformsListFromDropdownMenu.click();
  2150.         return new CompanyPortfolioPage(driver);
  2151.     }
  2152.    
  2153.     /**
  2154.      * Checks if the drop down list contains 'owners' option
  2155.      *  
  2156.      * @return                      true or false.
  2157.      */
  2158.     public boolean isContainsOwnersInGroupBy(){
  2159.         boolean isContains;
  2160.         isContains = common.isContain(pivotFiltersList,"Owner");
  2161.         return isContains;
  2162.     }
  2163.    
  2164.     /**
  2165.      * Checks if the search filters list contains 'owners' option
  2166.      *
  2167.      * @return                      true or false.
  2168.      */
  2169.     public boolean isContainsOwnersInSearchFilters(){
  2170.         boolean isContains;
  2171.         isContains = common.isContain(listOfFilters,"Owner");
  2172.         return isContains;
  2173.     }
  2174.    
  2175.     /**
  2176.      * Checks if the industry average list is not wrapped.
  2177.      *
  2178.      * @return                      true or false.
  2179.      */
  2180.     public boolean isIndustryAverageListIsNotWrapped(){
  2181.         boolean isNotWrapped;
  2182.         isNotWrapped = common.isElementInside(industryAverageList);
  2183.         return isNotWrapped;
  2184.     }
  2185.    
  2186.     /**
  2187.      * Checks if the conversation column text correct or not.
  2188.      *
  2189.      * @return                      true or false.
  2190.      */
  2191.     public boolean isConversationStrengthColumnTextCorrect(){
  2192.         String text;
  2193.         boolean isCorrect = false;
  2194.         text = conversationStrengthColumnTwitter.getText();
  2195.         if(text.contains("Conversation")){
  2196.             isCorrect = true;
  2197.         }
  2198.         return isCorrect;
  2199.     }
  2200.    
  2201.     /**
  2202.      * Sets 'display:"block;"' parameter for Account Settings
  2203.      *
  2204.      */
  2205.     public void mouseOverAccountSettings(){
  2206.         WebElement icon;
  2207.         icon = socialProfileForm.findElement(By.cssSelector(cssSettingsIcon));
  2208.         common.mouseOver(icon);
  2209.        
  2210.         int counter = 0;
  2211.         do{
  2212.             common.displayBlock(xpathHoverHelperDiv);
  2213.             common.displayBlock(xpathAccountSettings);
  2214.             counter ++;
  2215.         }
  2216.         while(!common.isElementDisplayed(edit) && counter < 6);    
  2217.     }
  2218.    
  2219.    
  2220.    
  2221.    
  2222.     /**
  2223.      * Mouse over Import Export
  2224.      *
  2225.      */
  2226.     public void mouseOverImportExport(){
  2227.         common.mouseOverJQuery((".profileSettings"));      
  2228.     }
  2229.    
  2230.    
  2231.    
  2232.     /**
  2233.      * Clicks on edit account link.
  2234.      *
  2235.      * @return AddSocialAccountsForm page object.
  2236.      */
  2237.     public AddSocialAccountsForm clickEditLink(){
  2238.         logger.debug("Click [Edit] link ");
  2239.        
  2240.         this.mouseOverAccountSettings();
  2241.         editAccountLink.click();
  2242.         return new AddSocialAccountsForm(driver);      
  2243.     }
  2244.    
  2245.     /**
  2246.      * Mouse over settings image using selenium mouse over.
  2247.      *
  2248.      */
  2249.     public void seleniumMouseOverSettingsImage() {
  2250.         common.mouseOver(importExportLink);
  2251.     }
  2252.    
  2253.     /**
  2254.      * Checks if the red border is displayed or not.
  2255.      *
  2256.      * @return                      true or false.
  2257.      */
  2258.     public boolean isRedBorderDisplayed(){
  2259.         boolean isDisplayed;
  2260.         isDisplayed = common.isElementDisplayed(redBorder);
  2261.         return isDisplayed;
  2262.     }
  2263.    
  2264.     /**
  2265.      * Checks if the only one platform name is displayed or not.
  2266.      *
  2267.      * @param platformName          platform name to check.
  2268.      *
  2269.      * @return                      true or false.
  2270.      */
  2271.     public boolean isOnlyOnePlatfromDisplayed(String platformName){
  2272.         boolean isOnlyOne;
  2273.         isOnlyOne = common.isOnlyOneElementFromListDisplayed(listofSoc, platformName);
  2274.         return isOnlyOne;
  2275.     }
  2276.    
  2277.     /**
  2278.      * Checks if the region is correct.
  2279.      *
  2280.      * @param region                regions to check.
  2281.      *
  2282.      * @return                      true or false.
  2283.      */
  2284.     public boolean isRegionCorrect(String region){
  2285.         boolean isCorrect;
  2286.         this.clickAssocitionsLinks();
  2287.         isCorrect = common.isContain(regions, region);
  2288.         return isCorrect;
  2289.     }
  2290.    
  2291.     /**
  2292.      * Checks if the LinkedIn image is displayed or not.
  2293.      *
  2294.      * @return                      true or false.
  2295.      */
  2296.     public boolean isLinkedinImageDisplayed(){
  2297.         boolean isDisplayed;
  2298.         isDisplayed = common.isElementDisplayed(linkedinImg);
  2299.         return isDisplayed;
  2300.     }
  2301.    
  2302.     /**
  2303.      * Checks if the triangle image near accounts name is on the same height as accounts name.
  2304.      *
  2305.      * @return                      true or false.
  2306.      */
  2307.     public boolean isTriangleOfAccountIsNotWrapped(){
  2308.         boolean isNotWrapped;
  2309.         isNotWrapped = common.isElementsOnTheSameRow(allListPage, cssSpanWithArrow, cssAccountNameSpan);
  2310.         return isNotWrapped;
  2311.     }
  2312.    
  2313.     /**
  2314.      * checks if the accounts name is on the same height as the social network icon.
  2315.      *
  2316.      * @return                      true or false.
  2317.      */
  2318.     public boolean isAccountNameisRelativeToSocialNetworkIcon(){
  2319.         boolean isRelative;
  2320. //      isRelative = common.isElementAligningRelativeTo(this.allListPage,".//img",
  2321. //              ".//span[@class='withoutDisplayName withoutDisplayWidth']");
  2322.         isRelative = common.isElementAligningRelativeTo(allListPage,".//img",
  2323.                 "..//span[@class='withoutDisplayName withoutDisplayWidth']" +
  2324.                 "|//i[@class='ellipsis display_nameEllipsis']");
  2325.         return isRelative;
  2326.     }
  2327.    
  2328.     /**
  2329.      * Expands needed number of accounts.
  2330.      *
  2331.      * @param numberOfAccounts      number of accounts to open.
  2332.      */
  2333.     public void expandAccounts(int numberOfAccounts){
  2334.         common.expandsAccounts(accountUserList, numberOfAccounts);
  2335.     }
  2336.    
  2337.     /**
  2338.      * Checks if the filter labels are selected alphabetically or not.
  2339.      *
  2340.      * @return                      true or false.
  2341.      */
  2342.     public boolean areFiltersSortedByAlphabeticaly(){
  2343.         boolean areSorted;
  2344.         areSorted = this.areFilterLabelsSortedAlphabetically(filterLabels);
  2345.         return areSorted;
  2346.     }
  2347.    
  2348.     /**
  2349.      * Checks if the list of selected filers is displayed or not.
  2350.      *
  2351.      * @return                      true or false.
  2352.      */
  2353.     public boolean isListOfSelectedFiltersDisplayed(String filtername){
  2354.         List <WebElement> listOfFilters = null;
  2355.         boolean isDisplayed;
  2356.         try{
  2357.             listOfFilters = selectedFilters.findElements(By.xpath(xpathListOfSelectedFilters));
  2358.         }
  2359.         catch (Exception e){
  2360.             listOfFilters = listOfSelectedFilters;
  2361.         }
  2362.         isDisplayed = common.isContain(listOfFilters, filtername);
  2363.         return isDisplayed;    
  2364.     }
  2365.    
  2366.     /**
  2367.      * Checks if the social accounts is displayed or not.
  2368.      *
  2369.      * @return                      true or false.
  2370.      */
  2371.     public boolean isSocialAccountLisDisplayed(){
  2372.         boolean isDisplayed;
  2373.         isDisplayed = common.areAllElemementsFromListDisplayed(socialAccountsList);
  2374.         return isDisplayed;    
  2375.     }
  2376.    
  2377.     /**
  2378.      * Checks if the only one social network is displayed or not.
  2379.      *
  2380.      * @param network               network that should be displayed.
  2381.      *  
  2382.      * @return                      true or false.
  2383.      */
  2384.     public boolean isOnlyOneSocialNetworkDisplayed(String network){
  2385.         boolean isDisplayed;
  2386.         isDisplayed = common.isOnlyOneElementFromListDisplayed(listofSoc, network);
  2387.         return isDisplayed;
  2388.     }
  2389.    
  2390.     /**
  2391.      * Clicks 'clear all filters' link.
  2392.      *
  2393.      * @return CompanyPortfolioPage page object.
  2394.      */
  2395.     public CompanyPortfolioPage clickClearAllFilters(){
  2396.         logger.debug("Click [Clear all filters] link ");
  2397.        
  2398.         clearAllFiltersHref.click();
  2399.         return new CompanyPortfolioPage(driver);
  2400.     }
  2401.    
  2402.     /**
  2403.      * Clicks 'clear all filters' link.
  2404.      *
  2405.      */
  2406.     public void clickClearAllFiltersNoAjax(){
  2407.         clearAllFiltersHref.click();
  2408.     }
  2409.    
  2410.     /**
  2411.      * Checks if the filter checkboxes checked.
  2412.      *
  2413.      * @return                      true or false.
  2414.      */
  2415.     public boolean isFilterCheckboxesChecked(){
  2416.         boolean isChecked;
  2417.         isChecked = common.isAllCheckboxesChecked(filterCheckboxes);
  2418.         return isChecked;  
  2419.     }
  2420.    
  2421.     /**
  2422.      * Checks if the filter checkboxes unchecked.
  2423.      *
  2424.      * @return                      true or false.
  2425.      */
  2426.     public boolean isFilterCheckboxesUnchecked(){
  2427.         boolean isUnchecked;
  2428.         isUnchecked = common.isAllCheckboxesUnchecked(filterCheckboxes);
  2429.         return isUnchecked;
  2430.     }
  2431.    
  2432.     /**
  2433.      * Checks if the selected filter is displayed.
  2434.      *
  2435.      * @return                      true or false.
  2436.      */
  2437.     public boolean selectedFiltersIsDisplayed(){
  2438.         boolean isDisplayed;
  2439.         isDisplayed = common.isElementDisplayed(selectedFiltersTitle);
  2440.         return isDisplayed;
  2441.     }
  2442.    
  2443.     /**
  2444.      * Checks if the Edit link is displayed or not.
  2445.      *
  2446.      * @return                      true or false.
  2447.      */
  2448.     public boolean isEditLinkDisplayed(){
  2449.         boolean isDisplayed;
  2450.         isDisplayed = common.isElementDisplayed(editAccountLink);
  2451.         return isDisplayed;
  2452.     }
  2453.    
  2454.     public void waitUntilLoadingComplete(){
  2455.         common.waitForElementHide(".//*[@id='filters']/div/p/span");
  2456.     }
  2457.    
  2458.     /**
  2459.      * Check if the ajax is used or not
  2460.      *
  2461.      * @param ajax.             number of ajax requests to check.  
  2462.      *
  2463.      * @return                  true or false.
  2464.      */
  2465.     public boolean isAjaxIsUsed(int ajax){
  2466.         boolean isAjaxUsed;
  2467.         isAjaxUsed = common.isAjaxUsedOrNot(ajax);
  2468.         return isAjaxUsed;
  2469.     }
  2470.    
  2471.     /**
  2472.      * Maximizes window.
  2473.      */
  2474.     public Dimension getWindowSize(){
  2475.         Dimension windowSize = common.getWindowSize();
  2476.         return windowSize;
  2477.     }
  2478.    
  2479.     /**
  2480.      * Switch to Facebook page.
  2481.      *
  2482.      */
  2483.     public void switchToFacebook(){
  2484.         common.switchToWindowUsingTitle("Facebook");
  2485.     }
  2486.    
  2487.     /**
  2488.      * Checks if the first windows smaller then seconds .
  2489.      *
  2490.      * @param firstDimension            first window dimension.
  2491.      *  
  2492.      * @param secondDimension           second window dimension.
  2493.      *
  2494.      * @return                          true or false.
  2495.      */
  2496.     public boolean isFirstElementSmaller(Dimension firstDimension , Dimension secondDimension){
  2497.         boolean isSmaller;
  2498.         isSmaller = common.isFirstElementSmaller(firstDimension, secondDimension);
  2499.         return isSmaller;
  2500.     }
  2501.    
  2502.     /**
  2503.      * Checks if the Account is first in the list.
  2504.      *
  2505.      * @param accountName                   account name.
  2506.      *
  2507.      * @return                              true or false.
  2508.      */
  2509.     public boolean isAccountIsFirstInlist(String accountName){
  2510.         boolean isFirst;
  2511.         isFirst = common.isFirstInList("//span[contains(@class,'withoutDisplayName')]", accountName);
  2512.         return isFirst;
  2513.     }
  2514.     /**
  2515.      * Refreshs page.
  2516.      *
  2517.      * @return  CompanyPortfolioPage page object.
  2518.      */
  2519.     public CompanyPortfolioPage refreshPage(){
  2520.         driver.navigate().refresh();
  2521.         return new CompanyPortfolioPage(driver);
  2522.     }
  2523.    
  2524.     public void waitForLoad(){
  2525.         common.waitForAjax("2");   
  2526.         common.waitForAjax("0");   
  2527.         common.waitForElement(".name");
  2528.     }
  2529.     /**
  2530.      * Takes list of filters.
  2531.      *
  2532.      * @param xpath         xpath of filters.
  2533.      *
  2534.      * @return listOfFilters.
  2535.      */
  2536.     public List<String> listOfSelectedFilters(String xpath){
  2537.         List<String> listOfFilters = new ArrayList<String>();
  2538.         listOfFilters = common.listOfSelectedFilters(xpath);
  2539.         return listOfFilters;
  2540.     }
  2541.    
  2542.     /**
  2543.      * Checks if the accounts are filtered or not.
  2544.      *
  2545.      * @param listofFilters             list of filters.
  2546.      *
  2547.      * @param xpath                     xpath of account details.
  2548.      *
  2549.      * @return                          true or false.
  2550.      */
  2551.     public boolean isAccountsAreFiltered(List<String> listofFilters, String xpath){
  2552.         boolean isFiltered;
  2553.         isFiltered = common.isAccountsAreFiltered(listofFilters, xpath);
  2554.         return isFiltered;
  2555.     }
  2556.    
  2557.     /**
  2558.      * Gets accounts from xls file.
  2559.      *
  2560.      * @param path                  file path of xls file.
  2561.      *
  2562.      * @return                      true or false.
  2563.      */
  2564.     public ArrayList<String> getAccountsFromXlsFile(String path){
  2565.         ArrayList<String> accounts = new ArrayList<String>();
  2566.         accounts = common.getAccountsFromXlsFile(path);
  2567.         return accounts;       
  2568.     }
  2569.    
  2570.     /**
  2571.      * Gets accounts from xls file.
  2572.      *
  2573.      * @param path                  file path of xls file.
  2574.      *
  2575.      * @param sheet                 number of sheet in xls file.
  2576.      *  
  2577.      * @return                      true or false.
  2578.      */
  2579.     public ArrayList<String> getAccountsFromXlsFile(String path, int sheet){
  2580.         ArrayList<String> accounts = new ArrayList<String>();
  2581.         accounts = common.getAccountsFromXlsFile(path, sheet);
  2582.         return accounts;       
  2583.     }
  2584.    
  2585.     /**
  2586.      * Checks if the sheet in xls file present.
  2587.      *
  2588.      * @param filepath              file path of xls file.
  2589.      *
  2590.      * @param sheetNumber.          number of sheet in xls file.
  2591.      *  
  2592.      * @return                      true or false.
  2593.      */
  2594.     public boolean isSheetPresent(String filepath, int sheetNumber){
  2595.         boolean isPresent;
  2596.         isPresent = common.isSheetPresent(filepath, sheetNumber);
  2597.         return isPresent;
  2598.     }
  2599.    
  2600.     /**
  2601.      * Gets accounts from cvs file.
  2602.      *
  2603.      * @param path                  path of file.
  2604.      *
  2605.      * @return                      true or false.
  2606.      */
  2607.     public ArrayList<String> getAccountsNameFromCvsFile(String path){
  2608.         ArrayList<String> accounts = new ArrayList<String>();
  2609.         try {
  2610.             accounts = common.getAccountsNameFromCvsFile(path);
  2611.         } catch (IOException e) {
  2612.             e.printStackTrace();
  2613.         }
  2614.         return accounts;
  2615.     }
  2616.    
  2617.     /**
  2618.      * Deletes accounts.xls file
  2619.      */
  2620.     public void deleteAccountsXls(){
  2621.         common.deleteFile("C:\\accounts.xls");
  2622.     }
  2623.    
  2624.     /**
  2625.      * Clicks [Associations] links
  2626.      */
  2627.     public void clickAssocitionsLinks(){
  2628.         List <WebElement> listofLinks;
  2629.         listofLinks = socialProfileForm.findElements(By.xpath(xpathAssociationsLink));
  2630.         for(WebElement link : listofLinks){
  2631.             this.clickWithPageReturn(link);
  2632.         }
  2633.     }
  2634.     /**
  2635.      * Clicks on edit link.
  2636.      *
  2637.      * @return  AddSocialAccountsForm object .
  2638.      */
  2639.     public AddSocialAccountsForm clickOnSpecifiedEditAccountLink(){
  2640.         logger.debug("Click [Edit Account] link ");
  2641.        
  2642.         WebElement editLink;
  2643.         editLink = this.mouseOverRandomPercentComplete();
  2644.         editLink.click();
  2645.         return new AddSocialAccountsForm(driver);
  2646.     }
  2647.    
  2648.     /**
  2649.      * Checks if the accounts are sorted by conversation correctly or not.
  2650.      *
  2651.      * @param sortedBySiteList
  2652.      *
  2653.      * @return true or false.
  2654.      */
  2655.     public boolean isSortedByConversation(ArrayList<String> sortedBySiteList){
  2656.         boolean isEqual = true;
  2657.         int nextConversation, previousConversation;
  2658.         int listSize = sortedBySiteList.size();
  2659.         for(int a = 0, b = 1; b < listSize; a++, b++){
  2660.             previousConversation = Integer.parseInt(sortedBySiteList.get(a));
  2661.             nextConversation = Integer.parseInt(sortedBySiteList.get(b));
  2662.             if(previousConversation < nextConversation){
  2663.                 return false;
  2664.             }
  2665.         }
  2666.         return isEqual;
  2667.     }
  2668.    
  2669.     public void cleanNeededNetworkSocialAccounts(String network, String username, String password){
  2670.         List <WebElement> socAccounts;
  2671.         String accountName, headerText;
  2672.         ArrayList<String> accounts = new ArrayList<String>();
  2673.         headerText = "of";
  2674.         WebElement socialHeader;
  2675.         do{
  2676.             socialHeader = socialProfileForm.findElement(By.xpath(".//*[@id='"+ network +"_dd']/h3"));
  2677.             this.findAndCheckNeededSocialNetwork(network);
  2678.             socAccounts = socialProfileForm.findElements(By.xpath(".//span[@class='withoutDisplayName']"));
  2679.             for(WebElement account : socAccounts){
  2680.                 accountName = account.getText();           
  2681.                 if(accountName.contains("mister") || accountName.contains("accountname")){
  2682.                     accounts.add(accountName);
  2683.                 }
  2684.             }
  2685.             headerText = socialHeader.getText();
  2686.             this.deleteAccountsByNetworkAndName(username, password, accounts, network);
  2687.             accounts.clear();
  2688.             this.refreshPage();
  2689.         }
  2690.         while(headerText.contains("of"));
  2691.        
  2692.     }
  2693.    
  2694.     public CompanyPortfolioPage deleteAccountsByNetworkAndName(String username , String password, ArrayList<String> accounts, String network){
  2695.         for(String accountName : accounts){
  2696.             coreApi.removeSocialAccount(username, password, network, accountName);
  2697.         }
  2698.         return new CompanyPortfolioPage(driver);
  2699.        
  2700.     }
  2701.    
  2702.     /**
  2703.      * Checks if the platforms displayed or not.
  2704.      *
  2705.      * @param platformNameList
  2706.      *
  2707.      * @return true or false
  2708.      */
  2709.     public boolean isPlatformsDisplayed(ArrayList<String> platformNameList){
  2710.         WebElement platform;
  2711.         String path;
  2712.         for(String platformName : platformNameList){
  2713.             path = "//dl//dd/h3[contains(.,'" + platformName + "')]";
  2714.             try{
  2715.                 platform = socialProfileForm.findElement(By.xpath(path));
  2716.                 if(!common.isElementDisplayed(platform)){
  2717.                     return false;
  2718.                 }
  2719.             }catch(Exception e){
  2720.                 return false;
  2721.             }
  2722.         }
  2723.         return true;
  2724.     }
  2725.    
  2726.     /**
  2727.      * Gets group labels.
  2728.      *
  2729.      * @return list of labels
  2730.      */
  2731.     public List<WebElement> getGroupLabelList(){
  2732.         return socialAccount;
  2733.     }
  2734.    
  2735.     /**
  2736.      * Checks two lists to equality.
  2737.      *
  2738.      * @param brandsBefore
  2739.      * @param brandsAfter
  2740.      *
  2741.      * @return true or false
  2742.      */
  2743.     public boolean areAllBrandsDisplayed(List<WebElement> brandsBefore, List<WebElement> brandsAfter){
  2744.         boolean equal = false;
  2745.         String brandNameBefore, brandNameAfter;
  2746.         if(brandsBefore.size() == brandsAfter.size()){
  2747.             for(int i = 0; i < brandsBefore.size(); i++){
  2748.                 brandNameBefore = brandsBefore.get(i).getText();
  2749.                 brandNameAfter = brandsAfter.get(i).getText();
  2750.                 if(!brandNameBefore.equals(brandNameAfter)){
  2751.                     return equal;
  2752.                 }
  2753.             }
  2754.             return true;
  2755.         }
  2756.         return equal;
  2757.     }
  2758.    
  2759.     /**
  2760.      * Checks if all regions are displayed correctly or not.
  2761.      *
  2762.      * @param regionsListFromFilter
  2763.      * @param regionsGroupList
  2764.      *
  2765.      * @return true or false
  2766.      */
  2767.     public boolean areAllRegionsDisplayed(List<WebElement> regionsListFromFilter, List<WebElement> regionsGroupList){
  2768.         String lastElementText = regionsGroupList.get(regionsGroupList.size() - 1).getText();
  2769.         int numberOfNotAssignedRegions, numberOfRegionsFromSearchFilter, numberOfAssignedRegions;
  2770.         numberOfAssignedRegions = regionsGroupList.size();
  2771.         numberOfRegionsFromSearchFilter = regionsListFromFilter.size();
  2772.         boolean equal = false;
  2773.        
  2774.         if(lastElementText.contains(" Regions with no social accounts associated")){
  2775.             numberOfAssignedRegions--;
  2776.             numberOfNotAssignedRegions = numberOfRegionsFromSearchFilter - numberOfAssignedRegions;
  2777.             if(lastElementText.equals(numberOfNotAssignedRegions + " Regions with no social accounts associated")){
  2778.                 equal = true;
  2779.             }
  2780.         }else if(numberOfAssignedRegions == numberOfRegionsFromSearchFilter){
  2781.             equal = true;
  2782.         }
  2783.         return equal;
  2784.     }
  2785.    
  2786.     /**
  2787.      * Checks if all countries are displayed correctly or not.
  2788.      *
  2789.      * @param countriesListFromFilter
  2790.      * @param countriesGroupList
  2791.      *
  2792.      * @return true or false
  2793.      */
  2794.     public boolean areAllCountriesDisplayed(List<WebElement> countriesListFromFilter, List<WebElement> countriesGroupList){
  2795.         String lastElementText = countriesGroupList.get(countriesGroupList.size() - 1).getText();
  2796.         int numberOfNotAssignedCountries, numberOfCountriesFromSearchFilter, numberOfAssignedCountries;
  2797.         numberOfAssignedCountries = countriesGroupList.size();
  2798.         numberOfCountriesFromSearchFilter = countriesListFromFilter.size();
  2799.         boolean equal = false;
  2800.        
  2801.         if(lastElementText.contains(" Countries with no social accounts associated")){
  2802.             numberOfAssignedCountries--;
  2803.             numberOfNotAssignedCountries = numberOfCountriesFromSearchFilter - numberOfAssignedCountries;
  2804.             if(lastElementText.equals(numberOfNotAssignedCountries + " Countries with no social accounts associated")){
  2805.                 equal = true;
  2806.             }
  2807.         }else if(numberOfAssignedCountries == numberOfCountriesFromSearchFilter){
  2808.             equal = true;
  2809.         }
  2810.         return equal;
  2811.     }
  2812.    
  2813.     /**
  2814.      * Checks if needed account is assigned to owner or not.
  2815.      *
  2816.      * @param accountName
  2817.      *
  2818.      * @return true or false
  2819.      */
  2820.     public boolean isAccountOwnerAssigned(String accountName){
  2821.         WebElement owner;
  2822.         String ownerName;
  2823.        
  2824.         owner = socialProfileForm.findElement(By.xpath("//*[contains(normalize-space(text()),'" + accountName + "')]/../../td[@class='user']"));
  2825.         ownerName = owner.getText();
  2826.         if(ownerName.equals("+ assign acct owner")){
  2827.             return false;
  2828.         }
  2829.         return true;
  2830.     }
  2831.    
  2832.     /**
  2833.      * Gets account platform type name.
  2834.      *
  2835.      * @param accountName
  2836.      *
  2837.      * @return platform name
  2838.      */
  2839.     public String getAccountPlatformType(String accountName){
  2840.         WebElement platform;
  2841.         String attribute, platformName;
  2842.         platform = socialProfileForm.findElement(By.xpath(".//span[text()='" + accountName + "']/../../../.."));
  2843.         attribute = platform.getAttribute("id");
  2844.         platformName = attribute.substring(0, attribute.lastIndexOf("_"));
  2845.         return platformName;
  2846.     }
  2847.    
  2848.     /**
  2849.      * Clicks 'Account' filter.
  2850.      *
  2851.      * @return AccountFilter object
  2852.      */
  2853.     public AccountFilter clickAccountFilter(){
  2854.         accountFilerLink.click();
  2855.         return new AccountFilter(driver);
  2856.     }
  2857.    
  2858.     /**
  2859.      * Clicks [CompanyAssosiations] tab.
  2860.      *
  2861.      * @return CompanyPortfolioPage object
  2862.      */
  2863.     public CompanyPortfolioPage clickCompanyAssosiationsTab(){
  2864.         companyAssosiationsTab.click();
  2865.         return new CompanyPortfolioPage(driver);
  2866.     }
  2867.    
  2868.     /**
  2869.      * Gets region name on the [CompanyAssosiations] tab.
  2870.      *
  2871.      * @return region name.
  2872.      */
  2873.     public String getRegionNameFromCompanyAssosiationsTab(){
  2874.         String region;
  2875.         clickCompanyAssosiationsTab();
  2876.         region = regionName.getText();
  2877.         return region;
  2878.     }
  2879.    
  2880.     public String getSubsidiaryNameFromCompanyAssosiationsTab(){
  2881.         String subsidiary;
  2882.         clickCompanyAssosiationsTab();
  2883.         subsidiary = subsidiaryName.getText();
  2884.         return subsidiary;
  2885.     }
  2886. }
Add Comment
Please, Sign In to add comment