Checkbox click -- dynamically without modifying code | Selenium Forum
M
Posted on 20/09/2016
[b:1i8swzr4]Requirement: Need to click on checkboxes so that even in future if any new check box should be checked/existing should be unchecked, code should not be modified.[/b:1i8swzr4]

Trying to check "checkbox" [u:1i8swzr4]without[/u:1i8swzr4] using xpath.
[attachment=1:1i8swzr4]checkbox-dynamicclick.png[/attachment:1i8swzr4]

Able to compare values in array and print those values (only if they match). But in this scenario, unable to click on check box against those values
[attachment=0:1i8swzr4]checkbox-dynamicclick1.png[/attachment:1i8swzr4]

can you please review above code and let me know what need to be added for checking check boxes

M
Replied on 21/09/2016

why no xpath?


M
Replied on 21/09/2016

Trying to implement new example as suggested by you in Module 13-->exercise 3


M
Replied on 21/09/2016

we have never suggested that you don't use xpath.

please send a screen shot where you read it we will change it.

thank you.


M
Replied on 22/09/2016

Sorry. I could not properly convey what i want to say.

[u:3i0uluqm]Purpose of declaring checkbox values in array:[/u:3i0uluqm]

As per below screenshot, there are 2 array values. so if one of them need to be checked, we can find xpath of that particular check box and check it through selenium. But if in future, if one more record is added/deleted to this check box list then we are expected to change xpath again.

To overcome this, you suggested to check the check box of desired text without depending on xpath.

To implement above logic, all desired values that are expected to be checked are declared in an array and able to check those values. so that going forward if any new values are added/existing values deleted we can just modify array instead of modifying code.


M
Replied on 22/09/2016

we'll talk about this on skype.