TangibleDream TangibleDream - 9 days ago 6
Ruby Question

How do I set focus on an anchor?

I'm trying to activate a link by setting focus to it and sending an enter key.

example = find{:xpath,'//*[@id="whatever"]/div/a')
example.trigger(focus)
example.send_keys(:enter}


What am I missing?

Answer

Send an empty key to the element, so it gets focused.

example.send_keys ""