Quantcast
Channel: Pochampalli IT Labs
Viewing all articles
Browse latest Browse all 261

Tip : Code snippet of isSelected() and getAttribute("value") to validate checkbox in a Store page form using java-selenium-cucumber

$
0
0
Hi,

Use case : In a Store page form,
PASS the test : if the store belongs to an internal office
FAIL the test : if the store belongs to external office for sales

NOTE : While creating the Store in the form selected the checkbox so it is an internal store.

label and input type : Is Internal Store ( it is a check box )

@Then("^I verify all the Store details with the values given while creating a new Store$")
publicvoidi_verify_all_the_Store_details_with_the_values_given_while_creating_a_new_Store()throws Throwable {
try{
Log.debug("Comparing Internal Store with the selection while a new Store is created");
Log.debug("Internal Store value while the Store is created is=true");
Log.debug("Get Value of internal Store from UI: "+driver.findElement(By.xpath("//*[@id='isInternalStore']")).getAttribute("value"));

if(
(driver.findElement(By.xpath("//*[@id='isInternalStore']")).isSelected())&&
(driver.findElement(By.xpath("//*[@id='isInternalStore']")).getAttribute("value").toString().equals("true"))
){
Log.debug("Store is equals with the selection while account is created");
}else
{
Assert.fail("else block.......... Store is NOT internal one");
System.out.println("Store is NOT internal one");
}
}catch(Exception e){
Assert.fail("catch block.........Store is NOT internal one"+e);
System.out.println("Store is NOT internal one"+e);
}
}

- Sadakar Pochampalli 

Viewing all articles
Browse latest Browse all 261

Trending Articles