开发者

For loop causing error in Junit with Selenium while searching data in a column

i m getting error for my following for loop in junit3

    for(int开发者_运维百科 i=9;i<=58;i++)
    {
    x = selenium.getTable("//table[4].".i.".6");
    if(x == "single" || x = "OneToMany")
        {   
            found="true";
        }
        else 
        break;
        }

can someone solve my problem where i m going wrong Thanks in advance


Is this code really Java code?

As @matt-ball already said, instead of

if(x == "single" || x = "OneToMany")

should be

if ("single".equals(x) || "OneToMany".equals(x))

Note, that in Java you should not compare String with ==, but should use equals() instead.

Also following code looks strange for me:

x = selenium.getTable("//table[4].".i.".6");

Is this string concatenation? It looks like PHP code. A think in Java this should be like this:

x = selenium.getTable("//table[4]." + i + ".6");

or

x = selenium.getTable("//table[4]." + String.valueOf(i) + ".6");

or

x = selenium.getTable(String.format("//table[4].%d.6", i);


Perhaps it's because you're assigning x.

x = "OneToMany"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜