etaoin

2022-06-02T19:14:27.788699Z

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]"})

2022-06-02T19:19:10.053369Z

etaoin 0.4.6, chromedriver 102.0.5005.61, Windows 10

2022-06-02T19:19:24.518309Z

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

2022-06-02T19:24:29.606629Z

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

2022-06-02T19:39:26.176699Z

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']"}})

lread 2022-06-02T20:55:14.822589Z

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']"})

2022-06-02T21:13:39.459689Z

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.

lread 2022-06-02T21:14:02.166999Z

Hmmmm….

lread 2022-06-02T21:14:59.369989Z

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

2022-06-02T21:15:01.664139Z

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.

2022-06-02T21:15:45.072569Z

“both of those” == browser installations

2022-06-02T21:15:59.318139Z

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

borkdude 2022-06-02T21:16:30.793239Z

Have you tried on WSL2 by any chance?

lread 2022-06-02T21:16:37.577029Z

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

2022-06-02T21:18:37.859769Z

Sadly, no. WSL2 is verboten.

👍 1
borkdude 2022-06-02T21:19:04.789819Z

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

lread 2022-06-02T21:19:33.529299Z

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.

borkdude 2022-06-02T21:19:33.954659Z

or which one, actually?

2022-06-02T21:20:13.351229Z

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

borkdude 2022-06-02T21:21:08.817749Z

But which version of the library?

lread 2022-06-02T21:21:31.414669Z

I think he already mentioned above 0.4.6

👍 1
2022-06-02T21:21:44.631979Z

Yep, 0.4.6

lread 2022-06-02T21:22:27.923269Z

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?

2022-06-02T21:23:11.006679Z

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

lread 2022-06-02T21:24:06.104169Z

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.

2022-06-02T22:04:46.745209Z

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.

2022-06-02T22:38:05.581239Z

Might be a good item for the Troubleshooting section.

lread 2022-06-02T23:06:49.183459Z

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