@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);
但错误是:
失败:内容 java.lang.AssertionError:expected [[Ljava.lang.String; @ 25be7b63]但找到[[Home,Chatter,Campsites,Campsite Reservations,Countries,Table,SPP Email Domain]]
答案 0 :(得分:0)
使用
将List<String>
转换为String[]
String[] converted_all_elements = all_elements.toArray(new String[0]);
然后尝试一下,
Assert.assertArrayEquals( all_elements, x );
答案 1 :(得分:0)
您遇到此问题是因为您正在将字符串数组与ArrayList进行比较。
宣布你的&#39; x&#39;作为ArrayList,它应该工作:
列表x =新的ArrayList&lt;&gt;(Arrays.asList(&#34; Home&#34;,&#34; Chatter&#34;,&#34; Campsites&#34;,&#34; Campsite Reservations&# 34;,&#34;国家&#34;,&#34;表&#34;,&#34; SPP电子邮件域&#34;));