bbc / tal

TV Application Layer
http://bbc.github.com/tal
Other
559 stars 150 forks source link

Testing TAL - click() on elements #534

Closed dkondraszuk closed 1 year ago

dkondraszuk commented 4 years ago

Hi guys, I'm writing automated UI tests using selenium. I've encountered an issue when tried to click() on an element - seems like it does not work.

Is there any way to select/click on elements using JS?

Thanks!

tsadler1988 commented 4 years ago

Hi @dkondraszuk,

TAL doesn't handle mouse events (including click), only key press events.

Looking at a Puppeteer example, we use page.keyboard.press to navigate and select with our Chrome device config. This works because our key mappings - https://github.com/bbc/tal/blob/master/config/devices/chrome-20_0-default.json#L57 - map Chromium's directional and enter key presses to the relevant TAL virtual key events.

An alternative would be firing virtual TAL events directly e.g.:

 var KeyEvent = require('antie/events/keyevent');
 var Application = require('antie/application');
 var application = Application.getCurrentApplication();
 application.bubbleEvent(new KeyEvent('keydown', KeyEvent.VK_ENTER));
 application.bubbleEvent(new KeyEvent('keyup', KeyEvent.VK_ENTER));

See the implementation - https://github.com/bbc/tal/blob/master/static/script/devices/browserdevice.js#L307 - if you want to understand more.

quantuminformation commented 4 years ago

wow people still use this!

kukulaka commented 1 year ago

We have deprecated this project and there are no plans for active development going forward.

Please see the deprecation notice.