if-else code is not getting recognized

13 views
Skip to first unread message

sirikr...@gmail.com

unread,
Jun 11, 2018, 12:14:59 AM6/11/18
to Selenium Users
 
All the before and after code is getting executed but not this try block. Please help:


try
        {
            if (driver.findElement(By.xpath("//*[@id='00N300000052VEX']")).getText().contains("Block"))
            {
                driver.findElement(By.xpath("//*[@id='00N300000052VEX']")).clear();
                driver.findElement(By.xpath("//*[@id='00N300000052VEX']")).sendKeys("Accept");
            }
            else if (driver.findElement(By.xpath("//*[@id='00N300000052VEX']")).getText().contains("Accept"))
            {
           
                driver.findElement(By.xpath("//*[@id='00N300000052VEX']")).clear();
                driver.findElement(By.xpath("//*[@id='00N300000052VEX']")).sendKeys("Review");
           
            }
            else if (driver.findElement(By.xpath("//*[@id='00N300000052VEX']")).getText().contains("Review"))
            {
                driver.findElement(By.xpath("//*[@id='00N300000052VEX']")).clear();
                driver.findElement(By.xpath("//*[@id='00N300000052VEX']")).sendKeys("Block");
           
            }
        }

        finally
        {
            Util.printInfo("Saving the Account");
            homePage.click("SaveAccount");
        }

    }

Cassian Raja Thomas

unread,
Jun 11, 2018, 2:49:29 AM6/11/18
to seleniu...@googlegroups.com
May be it couldn't find "Block", "Accept", "Review". Use equalsIgnoreCase() instead of equals(). 
Not even the finally block ran?? Kindly check again

Thanks & Regards,
Cassian Raja .T

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1c9d0c2b-d127-4f0a-baae-ad65d03cad0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages