TESTAR_dev icon indicating copy to clipboard operation
TESTAR_dev copied to clipboard

[Webdriver] Items from select tag web elements have empty dimensions

Open ferpasri opened this issue 5 years ago • 1 comments

Description Webdriver (chromedriver): items from select tag web elements exists in the widget tree but they have empty dimensions (width = 0, height = 0)

Cause

  • Implementation is not obtaining the correct dimensions from DOM, or these elements have not DOM dimensions.
  • This seems to occur regardless of whether the select element is inside a web iframe or not.

image

Steps to reproduce

  • Disable activate window (tab) feature (#235 ) , this will allow you to open these web elements
  • Go to some web page with this "select" web element. Example: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select
  • Use Spy mode to open this element, and move the mouse over the widget. Items are not detected.
  • We can also debug the properties of the widgets in the getState method to check the empty dimensions: image

Solution

  • Investigate if the width and height values ​​can be obtained through the DOM, then implement a solution.
  • Derive Actions at Script level with WdDriver.executeScript feature (as WdHistoryBack or WdAttributeAction). Example:
document.getElementById('cars').value = 'volvo';
document.getElementById('cars').value = 'opel';

Warning: If the element exists inside an iframe

document.getElementById("iframeResult").contentWindow.document.getElementById("cars").value = 'volvo'
document.getElementById("iframeResult").contentWindow.document.getElementById("cars").value = 'opel'

ferpasri avatar Oct 14 '20 15:10 ferpasri

I believe select elements are not actionable by just using mouse movement/clicks! I've tried to script the selenium chrome driver to click on one of the options (even using the keyboard tabs) but couldn't make it work: it looks like mouse interaction with the select element is handled natively by the OS platform.

Possible solution: select an option via the selenium API, similar to the WdDriver.executeScript approach suggested by Fernando. Major Drawback: it deviates from testar's - use the mouse/keyboard only - approach

odipar avatar Jan 05 '21 10:01 odipar