Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

click Function does not correspond to top-left corner of the element

Aperta
#38 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, php
Ambito
testing-qa

Direzione di ricerca

Inizia riproducendo clickWithLeftButton e moveMouseOver con la configurazione fornita di Firefox, Selenium e geckodriver, confrontando il comportamento dell’offset con Chrome. Usa come riferimento le misurazioni dell’offset JavaScript fornite; il lavoro è completo quando l’offset richiesto seleziona l’angolo previsto dell’elemento nei test di accettazione di Firefox.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What are you trying to achieve?

We are trying to click an element in a webpage.

What do you get instead?

Wrong element (the left or the right element) gets clicked instead. Based on the documentation here clickWithLeftButton with offset should place the cursor on the upper left corner of the element, but with extensive testing, we've found out that the position of the cursor is actually at the center of the element. Note that we are writing acceptance tests for a web application. The same code works fine with Chrome (configuration below) but it does not work well with Selenium/Gecko/Firefox. We are using an RTL language (Persian) in UTF-8.

Part of the code that is failing :

        $I->moveMouseOver($class,10,10);
        $I->wait(1);
        $I->clickWithLeftButton($class,10,10);
Details

Codeception : 4
PHP : 7.2 Remi
Selenium : 3.8.1 with enablePassThrough function
Geckodriver : 0.26.0
Mozilla Firefox : 72.0.1
OS : Windows 10

acceptance.suite.yml:

# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

actor: AcceptanceTester
modules:
    enabled:
        - \Helper\Acceptance
        - WebDriver
        - Db
        - Asserts
    depends:
        - Db:
        - WebDriver:
        - Asserts:
    url: 'http://localhost/'
    config:
        WebDriver:
             url: 'http://localhost/'
             port: 4444
        Db:
            dsn: 'mysql:host=1.1.1.1;dbname=mysql;charset=utf8'
            user: 'root'
            password: 'password'
            populate: false
            cleanup: false
            reconnect: true

env:
    firefox:
        modules:
            config:
                WebDriver:
                  url: 'http://localhost/'
                  window_size: 1920*1080
                  browser: firefox
                  capabilities:
                    acceptInsecureCerts: true
                    unexpectedAlertBehaviour: 'accept'
                    binary: "/opt/firefox/firefox-bin"
    chrome:
        modules:
            config:
                WebDriver:
                  url: 'http://localhost/'
                  window_size: 1920*1080
                  browser: chrome
                  capabilities:
                     chromeOptions: # additional chrome options
                       args: ["--no-sandbox", "--disable-notifications", "--start-maximized", "--disk-cache-dir=null", "--aggressive-cache-discard", "--disable-dev-shm-usage"]

After a lot of trial-and-errors, we eventually fixed our problem using the following code. The code uses JS functionalities to find the width and height of an element, then moves the cursor and selects the top right corner (This is where we found out that its not selecting the top left corner) :


        $width = 'var a = document.evaluate(\''.$class.'\', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.offsetWidth; return a;';
        $width = $I->executeJS($width);
        var_dump($width);
        $height = 'var a = document.evaluate(\''.$class.'\', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.offsetHeight;  return a;';
        $height = $I->executeJS($height);
        var_dump($height);

        $I->moveMouseOver($class,(($width/2)),0);
        $I->wait(1);
        $I->clickWithLeftButton($class,(($width/2)),0);

Let me know if more information is needed.

Lingua principale
PHP
Stelle
39
Fork
25
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Codeception/module-webdriver

Tutte le issue di Codeception/module-webdriver

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.