if(!"".equals(MyFrnds.list_Friends))
{
System.out.println("There is friends list");
Actions action= new Actions(driver);
action.contextClick(MyFrnds.list_Friends).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform();
System.out.println("My first friend link is opened in new tab and clicking on Show more button if there are more than 12 friends ");
if(!"".equals(MyFrnds.list_Friends))
{
MyFrnds.btn_FrShowmore.click();
}else
{
System.out.println("There are no more than 12 records");
}
}
else
{
System.out.println("There are no friends to display. So clicking on these two links to add friends");
// Right on FITBASE MEMBERS link and open in new tab
Actions action= new Actions(driver);
action.contextClick(MyFrnds.lnk_Fitbasemem).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform();
// Right on Social network link and open in new tab
action.contextClick(MyFrnds.lnk_Socialnet).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform();
}
在第一行的上述代码中,我将If条件赋予(!"" .equals(MyFrnds.list_Friends)),但无论应用程序如何,它都会进入条件的第一部分,即使它不满足第一个条件。因此我们在执行脚本时遇到错误。任何人都可以在代码中提出错误的建议。
答案 0 :(得分:1)
!"".equals(MyFrnds.list_Friends)
不是空字符串,则 true
为MyFrnds.list_Friends
。例如,如果MyFrnds.list_Friends
为null
,则条件也会返回true
。您可能需要执行额外的null
检查,或者只使用StringUtils.isNotBlank(MyFrnds.list_Friends)
。