if-else code is not getting recognized

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

if-else code is not getting recognized

sirikranti07
 
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");
        }

    }

--
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 [hidden email].
To post to this group, send email to [hidden email].
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 | Threaded
Open this post in threaded view
|

Re: if-else code is not getting recognized

cassian
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

On Mon, Jun 11, 2018 at 2:26 AM, <[hidden email]> wrote:
 
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");
        }

    }

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABh6KKtQYQbyj0x7T6BfDrtcHJiMqKXJUcXEsaWFPaKLKWgeZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.