healenium / healenium-example-python

Apache License 2.0
8 stars 7 forks source link

[BUG]: Selenium 4.XX returns a dictionary for a WebElement #2

Closed mario-s closed 2 years ago

mario-s commented 2 years ago

Hi,

im trying to run a setup with with selenium xpra and Selenium 4.0.0/4.1.0. The browser starts and I'm able to navigate to a webpage and find an element. However the elemnt is not of type selenium.webdriver.remote.webelement.WebElementit is of type dict. So that means I can not interact with it via a click() action. Is the docker infrastructure not compatible with Selenium 4.x.x?

I'm using Python 3.8.5 with this is docker-compose file:

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.2.0
    ports:
      - "7878:7878"
    links:
      - db
    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.1
    container_name: selector-imitator
    restart: on-failure
    ports:
      - "8000:8000"
    networks:
      - healenium

  hlm-proxy:
    image: healenium/hlm-proxy:0.2.1
    container_name: hlm-proxy
    ports:
      - "8085:8085"
    volumes:
      - docker-log-volume:/var/log/dockerlogs
    environment:
      - "recovery-tries=1"
      - "score-cap=.6"
      - "heal-enabled=true"
      - "serverHost=localhost"
      - "serverPort=7878"
      - "imitatePort=8000"
    networks:
      - healenium

  hlm-selenium-webview:
    image: healenium/hlm-selenium-4-standalone-xpra:0.1.2

    restart: on-failure
    container_name: hlm-selenium-webview
    ports:
      - "4444:4444"
      - "8086:10000"
    volumes:
      - docker-log-volume:/var/log/dockerlogs
    networks:
      - healenium

volumes:
  docker-log-volume:

networks:
  healenium:

When I execute this python script, I get a dictionary, not the WebElement, as expected.

from selenium import webdriver
from selenium.commons.webdriver import By

firefox_options = webdriver.FirefoxOptions()
driver = webdriver.Remote(command_executor='http://localhost:8085', options=firefox_options)
driver.get("https://mdn.github.io/web-components-examples/life-cycle-callbacks/")
btn = driver.find_element(By.XPATH, '//button[contains(@class, "add")]')
type(btn)
mario-s commented 2 years ago

Update to this topic:

When I remove the Xpra container and launch a standalone Selenium 4.1.2 server on my machine, it neither works with Selenium 4 and the Proxy. Here are my setups and the outcomes.

The response from the proxy during a lookup for an element is different to the one from the server itself. Proxy:

{
    "value": {
        "ELEMENT": "4264a7dc-e356-49f4-b7d4-ae40986ad9a8"
    }
}

Selenium Standalone Server:

{
    "value": {
        "element-6066-11e4-a52e-4f735466cecf": "4264a7dc-e356-49f4-b7d4-ae40986ad9a8"
    }
}
lucielavickova-tesena commented 2 years ago

facing the same problem

Alex-Reif commented 2 years ago

Fixed in healenium/hlm-proxy:0.2.5