Fork me on GitHub
#etaoin
<
2022-06-02
>
jkrasnay19:06:27

I’m having a weird problem with etaoin and chromedriver. The following expression finds my desired element from the devtools console: $x(".//span[text()='Edit']"). However, none of the following etaoin calls return any elements: (query-all driver [{:tag :span :fn/text "Edit"}]) (query-all driver {:xpath ".//span[text()='Edit]"})

jkrasnay19:06:10

etaoin 0.4.6, chromedriver 102.0.5005.61, Windows 10

jkrasnay19:06:24

Any ideas what might be going on here, or how to further diagnose?

jkrasnay19:06:29

BTW (query-all driver {:xpath ".//span"}) works fine, returning all the spans. It seems to be something in the xpath conditional clause.

jkrasnay19:06:26

Hrm, looks like a chromedriver issue. The following also throws the error “Unable to locate element”:

(execute {:driver driver
          :method :post
          :path [:session (:session driver) :element]
          :data {:using "xpath" :value ".//span[text()='Edit']"}})

lread20:06:14

Hiya @jkrasnay, this type of query is working for me on macOS with chrome and chromedriver both at version 102.0.5005.61 (off etaoin master). Can you share your html snippit? Your search above is for an exact match so maybe there is some case-sensitivity or extra space? I successfully tried:

(e/query-all driver [{:tag :span :fn/text "Edit"}])
;; note your example above is missing the close single quote on Edit
(e/query-all driver {:xpath ".//span[text()='Edit']"})

jkrasnay21:06:39

Thanks @lee. I think it’s something particular to my setup. Weirdly, (a) the same xpath that fails when going through the driver succeeds when at the devtools console, so I think that rules out problems with case, weird spacing, etc., and (b) I get the exact same broken behaviour with chromedriver and msedgedriver.

lread21:06:02

Hmmmm….

lread21:06:59

I’ve made a few fixes on master but I can’t remember anything around this area…

jkrasnay21:06:01

The only thing I can think of is that both of those are managed by my company’s group policy, but that seems pretty unlikely since most stuff works fine.

jkrasnay21:06:45

“both of those” == browser installations

jkrasnay21:06:59

I’ll drop a message here if I figure it out.

borkdude21:06:30

Have you tried on WSL2 by any chance?

lread21:06:37

I do have a Windows 10 VM. I could retry there if you think it would help.

jkrasnay21:06:37

Sadly, no. WSL2 is verboten.

👍 1
borkdude21:06:04

I assume you're testing with a previous release right?

lread21:06:33

If you clone etaoin master I have added a bb tools-versions which might be handy to report back on what versions of drivers and browsers you are running.

borkdude21:06:33

or which one, actually?

jkrasnay21:06:13

This is all new testing. I don’t have anything that was working before.

borkdude21:06:08

But which version of the library?

lread21:06:31

I think he already mentioned above 0.4.6

👍 1
lread21:06:27

If you can I’d start real small, just a html file with <span>Edit</span> and see if you can reproduce. Maybe there is something else in the html that is tripping things up?

jkrasnay21:06:11

That’s a great idea! I’ll give that a try in a bit.

lread21:06:06

Cool, let us know how it goes. And if you can, report back versions of chrome and chromedriver. I’ll also fire up that Windows VM if you find you are still stuck.

jkrasnay22:06:46

OK, I got it. My previous step opened a link in a new tab. Even though the tab was in the foreground I guess the driver was still looking at the original tab. Calling switch-window-next fixes it.

jkrasnay22:06:05

Might be a good item for the Troubleshooting section.

lread23:06:49

Awesome! And thanks for the addition to the user guide @jkrasnay, it’ll certainly help others, I’m sure you are not the only one who hit this!

👍 2