bbc / tal

TV Application Layer

Home Page:http://bbc.github.com/tal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Testing TAL - click() on elements

dkondraszuk opened this issue · comments

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!

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.

commented

wow people still use this!

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

Please see the deprecation notice.