healenium / healenium-web

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

java.lang.NoSuchMethodError: 'org.jsoup.nodes.Node org.jsoup.nodes.Document.root()' #152

Closed praktheo closed 2 years ago

praktheo commented 2 years ago

Hi Team,

I am using Cucumber Selenium with page object model. After first run completed. I have changed the first name and last name element. I am seeing below error during healing.

Maven Dependency:

<dependency>
            <groupId>com.epam.healenium</groupId>
            <artifactId>healenium-web</artifactId>
            <version>3.1.6</version>
</dependency>

hlm-backend: Image: healenium/hlm-backend:3.1.4 Ports: 0.0.0.0:7878->7878/tcp, :::7878->7878/tcp

Exception Stack Trace: 10-28-2021 21:44:30 - [com.epam.healenium.handlers.proxy.BaseHandler / lookUp][WARN ] - Failed to find an element using locator By.id: firstName Reason: no such element: Unable to locate element: {"method":"css selector","selector":"#firstName"} (Session info: chrome=95.0.4638.54) For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'CHNMCT407601L', ip: '10.110.43.73', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.12' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 95.0.4638.54, chrome: {chromedriverVersion: 95.0.4638.54 (d31a821ec901f..., userDataDir: C:\Users\kamalasekaran.p\Ap...}, goog:chromeOptions: {debuggerAddress: localhost:59844}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: accept, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true} Session ID: b7de32e6ce9933535e06b9f51f6b565f *** Element info: {Using=id, value=firstName} Trying to heal... java.lang.NoSuchMethodError: 'org.jsoup.nodes.Node org.jsoup.nodes.Document.root()' at com.epam.healenium.treecomparing.JsoupHTMLParser.parse(JsoupHTMLParser.java:25) at com.epam.healenium.SelfHealingEngine.parseTree(SelfHealingEngine.java:273) at com.epam.healenium.SelfHealingEngine.findNearest(SelfHealingEngine.java:240) at com.epam.healenium.SelfHealingEngine.findNewLocations(SelfHealingEngine.java:198) at com.epam.healenium.service.impl.AbstractHealingServiceImpl.healLocator(AbstractHealingServiceImpl.java:54) at com.epam.healenium.service.impl.HealingServiceImpl.heal(HealingServiceImpl.java:42) at com.epam.healenium.handlers.proxy.BaseHandler.lookUp(BaseHandler.java:91) at com.epam.healenium.handlers.proxy.BaseHandler.findElement(BaseHandler.java:56) at com.epam.healenium.handlers.proxy.SelfHealingProxyInvocationHandler.invoke(SelfHealingProxyInvocationHandler.java:39) at com.sun.proxy.$Proxy20.findElement(Unknown Source) at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69) at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38) at com.sun.proxy.$Proxy23.sendKeys(Unknown Source) at pages.CheckoutFormPage.enterFirstName(CheckoutFormPage.java:33) at step_definitions.CheckoutFormSteps.enterFirstNameAndLastName(CheckoutFormSteps.java:33) at â?½.Enter first name: Test and last name: Automation(file:///C:/Users/kamalasekaran.p/avonbrochure_automated_uat/src/test/java/features/checkoutForm.fea ture:6)

Static Web Page:

The highlighted elements are changed and not healed

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
    <meta name="generator" content="Hugo 0.88.1">
    <title>Checkout example · Bootstrap v5.1</title>

    <link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/checkout/">

    <!-- Font Awesome CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
          integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <style>
      .bd-placeholder-img {
        font-size: 1.125rem;
        text-anchor: middle;
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
      }

      @media (min-width: 768px) {
        .bd-placeholder-img-lg {
          font-size: 3.5rem;
        }
      }
    </style>

    <!-- Custom styles for this template -->
    <link href="form-validation.css" rel="stylesheet">
  </head>
  <body class="bg-light">

<div class="container">
  <main>
    <div class="py-5 text-center">
      <img class="d-block mx-auto mb-4" src="https://getbootstrap.com/docs/4.0/assets/brand/bootstrap-solid.svg" alt="" width="72" height="57">
      <h2>Checkout form</h2>
      <p class="lead">Below is an example form built entirely with Bootstrap’s form controls. Each required form group has a validation state that can be triggered by attempting to submit the form without completing it.</p>
    </div>

    <div class="row g-5">
      <div class="col-md-5 col-lg-4 order-md-last">
        <h4 class="d-flex justify-content-between align-items-center mb-3">
          <span class="text-primary">Your cart</span>
          <span class="badge bg-primary rounded-pill">3</span>
        </h4>
        <ul class="list-group mb-3">
          <li class="list-group-item d-flex justify-content-between lh-sm">
            <div>
              <h6 class="my-0">Product name</h6>
              <small class="text-muted">Brief description</small>
            </div>
            <span class="text-muted">$12</span>
          </li>
          <li class="list-group-item d-flex justify-content-between lh-sm">
            <div>
              <h6 class="my-0">Second product</h6>
              <small class="text-muted">Brief description</small>
            </div>
            <span class="text-muted">$8</span>
          </li>
          <li class="list-group-item d-flex justify-content-between lh-sm">
            <div>
              <h6 class="my-0">Third item</h6>
              <small class="text-muted">Brief description</small>
            </div>
            <span class="text-muted">$5</span>
          </li>
          <li class="list-group-item d-flex justify-content-between bg-light">
            <div class="text-success">
              <h6 class="my-0">Promo code</h6>
              <small>EXAMPLECODE</small>
            </div>
            <span class="text-success">−$5</span>
          </li>
          <li class="list-group-item d-flex justify-content-between">
            <span>Total (USD)</span>
            <strong>$20</strong>
          </li>
        </ul>

        <form class="card p-2">
          <div class="input-group">
            <input type="text" class="form-control" placeholder="Promo code">
            <button type="submit" class="btn btn-secondary">Redeem</button>
          </div>
        </form>
      </div>
      <div class="col-md-7 col-lg-8">
        <h4 class="mb-3">Billing address</h4>
        <form class="needs-validation" novalidate>
          <div class="row g-3">
            <div class="col-sm-6">
              <label for="firstName1" class="form-label">First name</label>
              **<input type="text" class="form-control" id="firstName1" placeholder="" value="" required>**
              <div class="invalid-feedback">
                Valid first name is required.
              </div>
            </div>

            <div class="col-sm-6">
              <label for="lastName" class="form-label">Last name</label>
              **<input type="text" class="form-control" id="lastName1" placeholder="" value="" required>**
              <div class="invalid-feedback">
                Valid last name is required.
              </div>
            </div>

            <div class="col-12">
              <label for="username" class="form-label">Username</label>
              <div class="input-group has-validation">
                <span class="input-group-text">@</span>
                <input type="text" class="form-control" id="username" placeholder="Username" required>
              <div class="invalid-feedback">
                  Your username is required.
                </div>
              </div>
            </div>

            <div class="col-12">
              <label for="email" class="form-label">Email <span class="text-muted">(Optional)</span></label>
              <input type="email" class="form-control" id="email" placeholder="you@example.com">
              <div class="invalid-feedback">
                Please enter a valid email address for shipping updates.
              </div>
            </div>

            <div class="col-12">
              <label for="address" class="form-label">Address</label>
              <input type="text" class="form-control" id="address" placeholder="1234 Main St" required>
              <div class="invalid-feedback">
                Please enter your shipping address.
              </div>
            </div>

            <div class="col-12">
              <label for="address2" class="form-label">Address 2 <span class="text-muted">(Optional)</span></label>
              <input type="text" class="form-control" id="address2" placeholder="Apartment or suite">
            </div>

            <div class="col-md-5">
              <label for="country" class="form-label">Country</label>
              <select class="form-select" id="country" required>
                <option value="">Choose...</option>
                <option>United States</option>
              </select>
              <div class="invalid-feedback">
                Please select a valid country.
              </div>
            </div>

            <div class="col-md-4">
              <label for="state" class="form-label">State</label>
              <select class="form-select" id="state" required>
                <option value="">Choose...</option>
                <option>California</option>
              </select>
              <div class="invalid-feedback">
                Please provide a valid state.
              </div>
            </div>

            <div class="col-md-3">
              <label for="zip" class="form-label">Zip</label>
              <input type="text" class="form-control" id="zip" placeholder="" required>
              <div class="invalid-feedback">
                Zip code required.
              </div>
            </div>
          </div>

          <hr class="my-4">

          <div class="form-check">
            <input type="checkbox" class="form-check-input" id="same-address">
            <label class="form-check-label" for="same-address">Shipping address is the same as my billing address</label>
          </div>

          <div class="form-check">
            <input type="checkbox" class="form-check-input" id="save-info">
            <label class="form-check-label" for="save-info">Save this information for next time</label>
          </div>

          <hr class="my-4">

          <h4 class="mb-3">Payment</h4>

          <div class="my-3">
            <div class="form-check">
              <input id="credit" name="paymentMethod" type="radio" class="form-check-input" checked required>
              <label class="form-check-label" for="credit">Credit card</label>
            </div>
            <div class="form-check">
              <input id="debit" name="paymentMethod" type="radio" class="form-check-input" required>
              <label class="form-check-label" for="debit">Debit card</label>
            </div>
            <div class="form-check">
              <input id="paypal" name="paymentMethod" type="radio" class="form-check-input" required>
              <label class="form-check-label" for="paypal">PayPal</label>
            </div>
          </div>

          <div class="row gy-3">
            <div class="col-md-6">
              <label for="cc-name" class="form-label">Name on card</label>
              <input type="text" class="form-control" id="cc-name" placeholder="" required>
              <small class="text-muted">Full name as displayed on card</small>
              <div class="invalid-feedback">
                Name on card is required
              </div>
            </div>

            <div class="col-md-6">
              <label for="cc-number" class="form-label">Credit card number</label>
              <input type="text" class="form-control" id="cc-number" placeholder="" required>
              <div class="invalid-feedback">
                Credit card number is required
              </div>
            </div>

            <div class="col-md-3">
              <label for="cc-expiration" class="form-label">Expiration</label>
              <input type="text" class="form-control" id="cc-expiration" placeholder="" required>
              <div class="invalid-feedback">
                Expiration date required
              </div>
            </div>

            <div class="col-md-3">
              <label for="cc-cvv" class="form-label">CVV</label>
              <input type="text" class="form-control" id="cc-cvv" placeholder="" required>
              <div class="invalid-feedback">
                Security code required
              </div>
            </div>
          </div>

          <hr class="my-4">

          <button class="w-100 btn btn-primary btn-lg" type="submit">Continue to checkout</button>
        </form>
      </div>
    </div>
  </main>

  <footer class="my-5 pt-5 text-muted text-center text-small">
    <p class="mb-1">&copy; 2017–2021 Company Name</p>
    <ul class="list-inline">
      <li class="list-inline-item"><a href="#">Privacy</a></li>
      <li class="list-inline-item"><a href="#">Terms</a></li>
      <li class="list-inline-item"><a href="#">Support</a></li>
    </ul>
  </footer>
</div>

    <script src="../assets/dist/js/bootstrap.bundle.min.js"></script>

      <script src="form-validation.js"></script>
  </body>
</html>
praktheo commented 2 years ago

YAML:

version: "3.3"

services:

  db:
    image: postgres:11-alpine
    ports:
      - "5432:5432"
    volumes:
      - ./db/sql/init.sql:/docker-entrypoint-initdb.d/init.sql
    restart: always
    environment:
      - POSTGRES_DB=healenium
      - POSTGRES_USER=healenium_user
      - POSTGRES_PASSWORD=YDk2nmNs4s9aCP6K
    networks:
      - healenium

  healenium:
    image: healenium/hlm-backend:3.1.4
    ports:
      - "7878:7878"
    links:
      - db
    restart: always
    environment:
      - SPRING_CONTAINER_NAME=healenium
      - SPRING_POSTGRES_DB=healenium
      - SPRING_POSTGRES_USER=healenium_user
      - SPRING_POSTGRES_PASSWORD=YDk2nmNs4s9aCP6K
      - SPRING_POSTGRES_URL=jdbc:postgresql://db:5432/healenium?currentSchema=healenium
    networks:
      - healenium

  selector-imitator:
    image: healenium/hlm-selector-imitator:1
    restart: on-failure
    ports:
      - "8000:8000"

networks:
  healenium:
ElenaStepuro commented 2 years ago

Hello @praktheo ! To start healing process of locator you don't need to change your locator in test code. Healing will work if locator which you previously use has been changed in DOM. Correct me if I misunderstood you.

praktheo commented 2 years ago

I am doing a POC. So I need to check the static website whether the web elements are updated after locaters are changed in DOM.

I have edited my index.html of the static web page and check the webelements are updating in run time.

https://www.automatetheplanet.com/healenium-self-healing-tests/

I took above link as reference

Kindly let me know if I am doing anything wrong

image

praktheo commented 2 years ago

Kindly help me on this. Let me know if any other details needed.

rohitgera15 commented 2 years ago

I am also gettig the same issue. Kindly help in reolsing the issue.

rohitgera15 commented 2 years ago

Kindly help me on this. Let me know if any other details needed.

please let me know if you have resolved this issue. thanks.

Alex-Reif commented 2 years ago

Hello @praktheo , @rohitgera15 Please use org.jsoup 1.11.3v +