Given the following code: if (element(by.name("checkbox")).isSelected()) { element(by.name("checkbox")).click(); }
It always clicks on the checkbox no matter if it is previously selected or not, it is like it doesn't matter what it returns. I've also tried if (element(by.name("checkbox")).isSelected() == true) { element(by.name("checkbox")).click(); }
same results.
But when i put the code in expected, it works like a charm... ex: expect(element(by.name("checkbox")).isSelected().toBe(true));
gives the correct answer, if it is selected or not.
Is this a bug of Protractor or am I doing something wrong here?
PS: I have tried to run a similar code in selenium webdriver junit, and it works.
Aucun commentaire:
Enregistrer un commentaire