0
@Test(priority=4)
    public void content(){

        String[] x = {"Home", "Chatter", "Campsites", "Campsite Reservations", "Countries", "Table", "SPP Email Domain" };


        driver.findElement(By.xpath("//button[contains(@class,'salesforceIdentityAppLauncherHeader')]")).click();
        driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
        driver.findElement(By.xpath("//*[@title='Content']")).click();
        driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);   
        WebElement Lightning = driver.findElement(By.xpath("//span[text()='Content']"));
        boolean displayedStatus = Lightning.isDisplayed();
        Assert.assertEquals(displayedStatus, true);
        List<WebElement> text = driver.findElements(By.xpath("//span[@class='slds-truncate'][contains(@data-aura-rendered-by,':0;p')]"));
        System.out.println(text.size());
        List<String> all_elements = new ArrayList<>();  
        for(int i=0; i<text.size();i++){
        all_elements.add(text.get(i).getText());
        }
        System.out.println(all_elements);
        Assert.assertEquals(all_elements, x);

but the error is:

FAILED: content java.lang.AssertionError: expected [[Ljava.lang.String;@25be7b63] but found [[Home, Chatter, Campsites, Campsite Reservations, Countries, Table, SPP Email Domain]]

halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

0

Convert the List<String> to String[], using

String[] converted_all_elements = all_elements.toArray(new String[0]); 

And then try this,

Assert.assertArrayEquals( all_elements, x );
diyoda_
  • 5,274
  • 8
  • 57
  • 89
0

You are getting this issue because you are comparing a string array with ArrayList.

Declare your 'x' as ArrayList and it should work:

List x = new ArrayList<>(Arrays.asList("Home", "Chatter", "Campsites", "Campsite Reservations", "Countries", "Table", "SPP Email Domain"));

Nargis
  • 4,687
  • 1
  • 28
  • 45
  • I'm using below code using Testng, getting error Null Pointer exception – Bharghav Reddy May 03 '17 at 14:39
  • public static WebDriver driver; @BeforeTest public void Login() { WebDriver driver = new chromeDriver(); driver.get("xxx"); driver.findElement(By.name("xx")).sendKeys("xxx"); driver.findElement(By.id("xx")).sendKeys("xxx"); driver.findElement(By.id("Login")).click(); } @Test(priority=2) public void Marketingtab(){ driver.findElement(By.xpath("//button[contains(@class,'salesforceIdentityAppLauncherHeader')]")).click(); driver.findElement(By.xpath("//*[@title='Marketing']")).click(); – Bharghav Reddy May 03 '17 at 14:45
  • Error: FAILED: Marketingtab java.lang.NullPointerException at salesforce.Login_SF.Marketingtab(Login_SF.java:41) at – Bharghav Reddy May 03 '17 at 14:45
  • I cant make out much from your code,but for sure, some object is null that you are trying to access, please debug and check ,what exactly is null and why. – Nargis May 05 '17 at 05:52