Fork me on GitHub
#etaoin
<
2022-06-21
>
Pablo03:06:36

Hi! I’m new using etaoin. I’m calling (e/click-single driver [{:tag :div :class "faculty_course_title"} {:tag :a}]) but something is not working. The browser keeps on the same page and on REPL I’m having {:value nil} . Could someone can explain me why it is not going to the link on that tag? This is the HTML where that element is mounted:

<div class="faculty_course_title" title="Course Title">
                        <a href="...">
                            Course Title                        </a>
                    </div>

Pablo03:06:28

I’m using Safari’s driver

lread14:06:14

Hiya @UNUH8H85U! I’ll take a look sometime soon.

lread14:06:37

Hmm… I’m learning that safaridriver is rather limited. I can reproduce your issue with safaridriver Included with Safari 15.5 (15613.2.7.1.9).

lread14:06:49

I see some folks working around this limitation via JavaScript. I’ve saved your html to fiddle/slack20220621.html (but changed href to hit something for testing purposes):

<div class="faculty_course_title" title="Course Title">
 <a href="">Course Title</a>
</div>
Then from my REPL I open up your test page with safaridriver:
(require '[etaoin.api :as e]
         '[ :as io])

(def driver (e/safari))
(def test-page (-> "fiddle/slack20220621.html" io/file .toURI str))
(e/go driver test-page)
I can confirm this does not work for me either:
(e/click-single driver [{:tag :div :class "faculty_course_title"} {:tag :a}])
But as a work-around I tried using JavaScript to click on the element:
(let [elem (e/query driver [{:tag :div :class "faculty_course_title"} {:tag :a}])]
  (e/js-execute driver "arguments[0].click()" (e/el->ref elem)))
And that worked for me.

lread14:06:08

To anybody else reading this who ran into this problem, is this what you do as well for safaridriver?

Pablo22:06:18

Thanks a lot ☺️. I thought I was clicking the wrong DOM element. Is there a way to see safaridriver errors in order to know whats happening on next time?

lread02:06:48

As far as I understand so far, it is just a long standing bug in safaridriver. I suppose we could have Etaoin compensate for it, but not sure if that is a good idea yet.

1
Pablo17:06:36

Umm, ok. Thanks a lot!

lread16:06:41

The thought is if we start compensating for bugs in WebDriver implementations, how to we manage when they are eventually fixed? And if we compensate… maybe that’s too much magic? Perhaps a note in the user guide with the above work-around might be the better way to go.