healenium / healenium-web

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

Getting error "javascript error: Cannot read properties of undefined (reading 'toLowerCase')" #155

Open Vishnupk1993 opened 2 years ago

Vishnupk1993 commented 2 years ago

If you didn't see the video how to use Healenium, please, firstly, get it know on link https://healenium.io/

Describe the problem A clear and concise description of what the problem you've faced with

Screenshots If applicable, add screenshots to help explain your problem.

Please complete the following information:

  1. Versions of components (web and backend)
  2. Selenium version
  3. Platform (Java, .NET, etc)
  4. Full stacktrace with exception
  5. Logs from healenium-backend container
  6. WebDriver creation

Additional context Add any other context about the problem here. For example, using of additional frameworks like Sizzle library, Robot Framework or JDI, etc.

Vishnupk1993 commented 2 years ago

Getting error during execution at the below line , seleniumWebdriver = SelfHealingDriver.create(seleniumWebdriver);

Error ChromeDriver was started successfully. Exception in thread "main" org.openqa.selenium.JavascriptException: javascript error: Cannot read properties of undefined (reading 'toLowerCase')

ElenaStepuro commented 2 years ago

Hello @Vishnupk1993 ! Unfortunately, I cannot help because of lack of information. Please, fill as much fields in issue template as possible to help you.

Vishnupk1993 commented 2 years ago

Please find more details below.

Problem Description Getting error during execution at the below line , seleniumWebdriver = SelfHealingDriver.create(seleniumWebdriver);

1)Versions of components (web and backend) - Healenium Web version : 3.1.6 , Docker Version : Version 2.0.0.3 (31259)
2)Selenium version : - selenium-server-4.0.0 3)Platform (Java, .NET, etc) - Java 4)Logs from healenium-backend container - image

5)WebDriver creation

WebDriverManager.chromedriver().setup(); ChromeOptions options = new ChromeOptions(); WebDriver seleniumWebdriver = new ChromeDriver(options); seleniumWebdriver = SelfHealingDriver.create(seleniumWebdriver);

6) Sample code : package healenium; import java.util.List; import java.util.concurrent.TimeUnit; import com.epam.healenium.SelfHealingDriver; import com.epam.healenium.SelfHealingDriver; import io.github.bonigarcia.wdm.WebDriverManager; import org.openqa.selenium.*; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; public class SampleHeal {

public static void main(String[] args) throws InterruptedException {

    WebDriverManager.chromedriver().setup();
    ChromeOptions options = new ChromeOptions();
    WebDriver seleniumWebdriver = new ChromeDriver(options);
    seleniumWebdriver = SelfHealingDriver.create(seleniumWebdriver);
    seleniumWebdriver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
    seleniumWebdriver.manage().window().maximize();
    seleniumWebdriver.manage().window().setSize(new Dimension(108,240));
    seleniumWebdriver.get("xyz.com");
    seleniumWebdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    seleniumWebdriver.findElement(By.xpath("abc")).sendKeys("abc");
    seleniumWebdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    seleniumWebdriver.findElement(By.xpath("abc")).sendKeys("abc");
    seleniumWebdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    seleniumWebdriver.findElement(By.xpath("abc")).click();
    seleniumWebdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    Thread.sleep(3000);
    seleniumWebdriver.findElement(By.xpath("abc")).click();
    seleniumWebdriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    Thread.sleep(2000);
    seleniumWebdriver.findElement(By.xpath("abc")).click();
    seleniumWebdriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    Thread.sleep(2000);
    seleniumWebdriver.findElement(By.xpath("abc")).click();
    seleniumWebdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

} }

7) Error screenshot :- image

ElenaStepuro commented 2 years ago

Hello @Vishnupk1993 ! Unfortunately, for now healenium not integrated with Selenium 4.0.0. Please, use 3.141.59 version if you can. To know about related updates you can see this issue https://github.com/healenium/healenium/issues/1 Also, please, add another one container healenium/hlm-selector-imitator:1, as in example, docker-compose In addition, do not forget to add healenium.properties file to your project

Vishnupk1993 commented 2 years ago

Hi @ElenaStepuro ! Thanks for the quick update.

Tried the same. I have changed the version to 3.141.59 version, added another container. But still we are getting the same error. Attaching the screenshots:- 1)Docker :- image 2) Error Screenshot:- image 3)Selenium version:- image

ElenaStepuro commented 2 years ago

Hello @Vishnupk1993 ! In this case, it could be because of incompatibility of chrome driver, chrome browser and selfhealingdriver. I recommend to change chrome driver version to use chrome 92 if you can

ElenaStepuro commented 2 years ago

In addition, @Vishnupk1993 , please, send full stacktrace of problem and pom.xml to check your dependencies. I've rechecked your test example on my machine and it run without problems.

Vishnupk1993 commented 2 years ago

Hi @ElenaStepuro ! Please find the details below :- POM XML : Pomhealenium.txt Logs :- Logs_Healenium.txt

Note : - We tried the same in Salesforce community edition. My current chrome version is 95, Please let me know how to check in a lower version through selenium.

ElenaStepuro commented 2 years ago

Hi @Vishnupk1993 ! I've rechecked your example on Chrome 95. No worries about it: you don't need to decrease browser version. But I'm worried about this warning from your log: [1636722946.998][WARNING]: This version of ChromeDriver has not been tested with Chrome version 95.

I use chromedriver 95.0.4638.69 and your version is ChromeDriver 94.0.4606.61. Try to increase chromedriver version. As I can see from log file, it's not healenium issue. It's somewhere in Selenium, most possible it's browser and driver integration.

Vishnupk1993 commented 2 years ago

Hi @ElenaStepuro ! We did exactly like you said but still the issue exists , Please find the below logs. Logs_Healenium.txt

ElenaStepuro commented 2 years ago

Hi @Vishnupk1993 ! Interesting... can we have a call?

Vishnupk1993 commented 2 years ago

hi @ElenaStepuro

Greetings ! Can you please help me to understand how the elements are getting stored in docker ? and can we view the stored web elements through docker ?.

ElenaStepuro commented 2 years ago

Hello @Vishnupk1993 You can find stored web elements in database using hlm-backend container. And yes, you can view those web elements from db through docker

Vishnupk1993 commented 2 years ago

Thanks for the update @ElenaStepuro , we tried in salesforce lightning and only the login part is getting healed. But we are not getting the report , is there any other dependency or do we need to add any extra line code to get the same ?

ppty file.txt YML_AR.txt

the above attached are the yml and ppty file which we are using now.

ElenaStepuro commented 2 years ago

Hello @Vishnupk1993 As about docker containers, everything looks correct. Be informed that hlm-back 3.1.4 not compatible with 3.2.0+ hlm-web versions. As about healenium properties, we don't have basePath, reportPath and screenshotPath properties.

For generating report the next points should be completed:

Then you'll see link for generated report like here image

In addition, you can see the video about plugin's setup and run: https://www.youtube.com/watch?v=hwSK5ngqOgQ&ab_channel=HealeniumCommunity

Vishnupk1993 commented 2 years ago

Hi @ElenaStepuro

We tried all the mentioned setups , we also referred few issuw #170. But the report is generating like the below

MicrosoftTeams-image

and also getting the below mentioned issues while running the script

*** Element info: {Using=xpath, value=//a[@id='forgot_password_link']} Trying to heal... [main] WARN com.epam.healenium.client.RestClient - Failed to make response of 'getLastHealingData' request.

ElenaStepuro commented 2 years ago

@Vishnupk1993 in previous comment forgot to say about other properties... Please, see my comment below:

Vishnupk1993 commented 2 years ago

@ElenaStepuro till now the same issue is getting repeated. Since it's my official code i cannot have a session with you too :( . Can you share me the latest updated yml , helaenium ppty files ?

Vishnupk1993 commented 2 years ago

i'm trying by adding break point's to check if the code is working or not. Please find the below step which i did during execution

Used intellij I have written a login code only,

1) so first time i run the code 2) Then next time i will add a break point in the login xpath 3) Once the screen is visible it will stop before clicking the login button 4) There i manually update the login xpath and resume the execution.

Previously this was working fine for me then i updated the pom and yml i guess

ElenaStepuro commented 2 years ago

Hello @Vishnupk1993 The latest yaml file you can find here: https://github.com/healenium/healenium-example-maven/blob/master/infra/docker-compose.yaml The latest back version here is 3.2.0 and it's compatible only with web 3.2.0 and 3.2.1 versions The latest healenium properties you can find here: https://github.com/healenium/healenium-example-maven/blob/master/src/test/resources/healenium.properties In addition, you can see this setup tutorial: https://www.youtube.com/watch?v=Ed5HyfwZhq4

As about your steps, you don't need to update login xpath in code. It should be changed in DOM om page

Vishnupk1993 commented 2 years ago

HI @ElenaStepuro

I tried the same in my Personal Laptop and the salesforce script which i have written is working fine, but the report is not generating. If possible can we have a connect to resolve the same ?

Similarly we are also facing some issue with healing driver in some script's too.

ElenaStepuro commented 2 years ago

Hello @Vishnupk1993 , yes, if you need we can have a call. Please, send me by e-mail elena_stepuro@epam.com available time slots for you on the next week.

Vishnupk1993 commented 2 years ago

Hi @ElenaStepuro , Thanks, i have shared you a mail please let me know about the time. If you are occupied with the mentioned IST please let me know your available time.

Vishnupk1993 commented 2 years ago

@ElenaStepuro We are waiting in the lobby for the clarification.

ElenaStepuro commented 2 years ago

@Vishnupk1993 I'm also in the lobby)

Vishnupk1993 commented 2 years ago

i thing you joined in the other lobby.

Vishnupk1993 commented 2 years ago

Hi @ElenaStepuro ,

Thanks for the clarification's , as discussed I have attached the folder in my drive and shared you. Please let me know if you require any further input's from our side.

Vishnupk1993 commented 2 years ago

Hi @ElenaStepuro any update on the same ? Thanks

ElenaStepuro commented 2 years ago

Hello @Vishnupk1993 , unfortunately, I didn't see your test example as we've discussed via call. Could you please resend it?

ElenaStepuro commented 2 years ago

Hello @Vishnupk1993 could you please, get an access to e-mail elenastepuro5005@gmail.com?

Vishnupk1993 commented 2 years ago

HI @ElenaStepuro Hope you got the access to the folder

Vishnupk1993 commented 2 years ago

95214 @ElenaStepuro Please use this code

Vishnupk1993 commented 2 years ago

*952143

Vishnupk1993 commented 2 years ago

Hi @ElenaStepuro greetings, any further update on that issue ?

ElenaStepuro commented 2 years ago

Hi @Vishnupk1993 , sorry for long answer. Unfortunately, for now there are no updates from my side. I will come back to you with updates till the end of this week. Thanks for understanding.

raghunadh10 commented 2 years ago

Hi @ElenaStepuro ! We did exactly like you said but still the issue exists , Please find the below logs. Logs_Healenium.txt

Hi

Hi @ElenaStepuro greetings, any further update on that issue ?

Hi @ElenaStepuro ! We did exactly like you said but still the issue exists , Please find the below logs. Logs_Healenium.txt

HI @Vishnupk1993 . I have encountered a smiliar issue which is "javascript error: Cannot read properties of undefined (reading 'toLowerCase')" . i have been using the correct versions of healenium web , backend and chrome. Healenium is working on other scenarios but not on this particular scenario where it is trying to find the web element . instead of finding it , it is throwing this error. Also when the disbale healing mode is on , it is running fine . can you please check out this problem and help me .

ElenaStepuro commented 2 years ago

Hi @raghunadh10 unfortunately, for now Healenium doesn't support Js executor. We work on this issue.

Alex-Reif commented 2 years ago

Hi @raghunadh10 , @Vishnupk1993 , Issue was fixed in hlm-web version 3.3.0

Vishnupk1993 commented 2 years ago

@Aliaksei-Ashukha Thanks for the resolution. Can you please share the latest yaml file ?

Alex-Reif commented 2 years ago

@Vishnupk1993 , Yaml file remain the same. You need to update hlm-web dependency

Vishnupk1993 commented 2 years ago

HI @Aliaksei-Ashukha While running the script i met with this below error, can you please provide a resolution for this ? java: warning: source release 10 requires target release 1.10

raghunadh10 commented 2 years ago

Hi @Aliaksei-Ashukha . thanks for the update . i have one doubt regarding database we are using in healenium . can we have the ability to change the constraints on columns like (example -- adding unique constraint to locator column) . will this create any issues ? please help me on this thing . if any extra details needed, please intimate me .

Alex-Reif commented 2 years ago

Hi @raghunadh10, If we talk locator column, there is no constraint of this one. What exactly column do you want to change ?

raghunadh10 commented 2 years ago

hi @Aliaksei-Ashukha . In the db , locator column getting stored with duplicate values too , i want to avoid it . so i am thinking to add a unique constraint on it . so on adding it, will it cause any unreasonable behavior by healenium.

Vishnupk1993 commented 2 years ago

Hi @Aliaksei-Ashukha tried the same thing and works as expected to me. Thanks for this fix. Quickly, can we set up healenium with eclipse? Because we use our own framework that will support the eclipse rather than intellij.

Alex-Reif commented 2 years ago

@raghunadh10 , Selector table also have URL, CLASS_NAME, METHOD_NAME. These values used for identify unique of locator. In case you have duplicate locator value, so URL, CLASS_NAME, METHOD_NAME should have other other value. (For example locator By.id("button"); can used on different pages.)

Alex-Reif commented 2 years ago

@Vishnupk1993 , Healenium does not depend on the IDE. You can use eclipse as well.

raghunadh10 commented 2 years ago

@Aliaksei-Ashukha , yeah right . i just saw it . thank you so much for the explanation . one last thing ashukha , so no matter how many times locator get stored or method_name got stored, healenium heals the webelement when its xpath got changed without any trouble right . the reason im asking this is for some web elements its unable to heal . its usually saying new element locator not found . may be im doing any mistake . can you please give some tips to make the best use of this healing ? thanks for your time again

Vishnupk1993 commented 2 years ago

Thanks for the update @Aliaksei-Ashukha , is there any plugin available for eclipse ? Like the Healenium plugin we used for intellij ?

Vishnupk1993 commented 2 years ago

Hi @Aliaksei-Ashukha I tried running the script through maven and for me the browser is not getting opened im getting these exceptions, can you please help me to debug this ? error log healenium.txt

@raghunadh10 is chrome opening for you through maven ?