Can someone explain to me in layman terms how command isEnabled() works in Appium Scenario: There are 3 checkboxes on a specific mobile page. - Checkbox 1, Checkbox2 & Checkbox3 “Checbox3” is disabled by default and only enables when we select “Checkbox2”
TC is to verify if “Checkbox3” is disabled by default and print the following output “Checkbox3 is currently Disabled”
Once the “Checkbox3” is enabled we need to print the following output “Checkbox3 is currently Enabled”
I am executing this as a TestNG and am using the following line of code
boolean FirstValue = XMLPage.ListofCheckboxes.get(2).isEnabled();
System.out.println(FirstValue);
if(FirstValue=false)
{
System.out.println("Checkbox3 is currently Disabled");
}
else
{
System.out.println("Checkbox3 is currently Enabled");
}
Thread.sleep(4000);
XMLPage.ListofCheckboxes.get(1).click();
boolean SecondValue = XMLPage.ListofCheckboxes.get(2).isEnabled();
System.out.println(SecondValue);
if(SecondValue=true)
{
System.out.println("Checkbox3 is currently Enabled");
}
else
{
System.out.println("Checkbox3 is currently Disabled");
}
Expected Output :
- false
- "Checkbox3 is currently Disabled"
- true
- "Checkbox3 is currently Enabled"
Actual Output:
- false
- "Checkbox3 is currently Enabled"
- true
- "Checkbox3 is currently Enabled"
The first time it encounters the if statement shouldn’t it print the output as "Checkbox3 is currently Disabled" I am not sure why it prints the output mentioned under ‘else’{i.e.:- "Checkbox3 is currently Enabled"}. As displayed in the output the value returned by command “boolean FirstValue = XMLPage.ListofCheckboxes.get(2).isEnabled();” is false and hence the code should print the output mentioned under ‘if’ and not ‘else’.