healenium / healenium-web

Self-healing library for Selenium Web-based tests
Apache License 2.0
169 stars 40 forks source link

Healenium - Selfhealing is not working with bySizzle library By bySizzle.css #148

Open swapnilshetes opened 3 years ago

swapnilshetes commented 3 years ago

Hi Team, Greeting of the day, I have implemented this feature and proper works with the docker , POM maven testng and in locater I am using findby/by to find the element e.g. " @FindBy(css="input#name") ". please check below details

############################################################## //Web Elements by using Page Factory @FindBy(css = "input#name") public WebElement name; @FindBy(css = "input#mobile") public WebElement mobile; @FindBy(css = "input#email") public WebElement email; @FindBy(css = "reasons") public WebElement reasons; @FindBy(css= "writeSomething") public WebElement writeSomething; @FindBy(css = "sub") public WebElement sub; #############################################################

Now I have updated FindBy/By with advance library using BySizzle e.g. " public By inputName() { return bySizzle.css("#name");}

################################################################## BySizzle bySizzle = new BySizzle();

  public By inputname (){    return bySizzle.css("#name");   }
  public By inputmobile (){    return bySizzle.css("#mobile");   }
  public By inputemail (){    return bySizzle.css("#email");   }
  public By inputreasons (){    return bySizzle.css("#reasons");   }
  public By inputwriteSomething (){    return bySizzle.css("#writeSomething");   }
  public By clicksubmit (){    return bySizzle.css("#sub");   }

########################################################################

"while testing in normal mode without updated element in html it is working fine with healing is enabled and when I tried with updated element and healing is enabled. It is not working as expected. It is not doing healing not trying to healing such element ("#name") using bySizzle.css get noSuchElement error.

Could you please assist me on this. It will help us a lot to understand Selfhealing-healenium .

Thanks, Swapnil

############################################################################### @FindBy(xpath = "//div[@class='contact-form']") public class RegistrationPage extends BasePage {

BySizzle bySizzle = new BySizzle();

//*********Web Elements by using Page Factory*********

/ @FindBy(css = "input#name") public WebElement name; @FindBy(css = "input#mobile") public WebElement mobile; @FindBy(css = "input#email") public WebElement email; @FindBy(css = "reasons") public WebElement reasons; @FindBy(css= "writeSomething") public WebElement writeSomething; @FindBy(css = "sub") public WebElement sub; /

        public By inputname (){    return bySizzle.css("#name");   }
        public By inputmobile (){    return bySizzle.css("#mobile");   }
        public By inputemail (){    return bySizzle.css("#email");   }
        public By inputreasons (){    return bySizzle.css("#reasons");   }
        public By inputwriteSomething (){    return bySizzle.css("#writeSomething");   }
        public By clicksubmit (){    return bySizzle.css("#sub");   }
swapnilshetes commented 3 years ago

Hi Team, Could you please guide us on this ?

Thanks, Swapnil

swapnilshetes commented 3 years ago

Hi Team, Could you please guide us on this ?

Thanks, Swapnil

ElenaStepuro commented 3 years ago

Hello @swapnilshetes ! Unfortunately, healenium doesn't integrated with Sizzle library(

swapnilshetes commented 3 years ago

Hi @ElenaStepuro,

Thank you for your reply and I request you if possible share with me some information on Locators which are identify by JavaScript.

please check below example :

HTML ::

Enter Uname

and Locater identify by JavaScript in selenium :

String selector = ".form-group:contains('Enter Username') > input"; String query = "return $(\"" + selector +"\").each(function(e) { return this;}).get(0)"; ((WebElement)((JavascriptExecutor) driver).executeScript(query)).sendKeys("This is Java");

So is this possible , can we heal this type of locater/element through this healing library.

Thanks, Swapnil

ElenaStepuro commented 2 years ago

Hello @swapnilshetes ! It's a known defect for js executor. I'll notify you when we include it into sprint to fix.

swapnilshetes commented 2 years ago

Hello thank you @ElenaStepuro to let us know.

As per my observation we haven't provided provision for findbyElement by JavaScript. object invoke(Object Proxy , Method method, Object args[]) using this method , we captured only selenium findby reference and not for Selenium JavaScript reference , so its automatically execute default option. and not execute healing.

Please let us know any help because 40% (this % is approx. ) elements are identify by javascript because of this , this good idea will fail. If possible, please request you update us asap.

Thanks, Swapnil

swapnilshetes commented 1 year ago

Hello @ElenaStepuro, Greetings of the day. Do we have any updates?

Thanks.