@mrg, try some xpath? If you fire up your browser debugger and select the item you want to click, there's usually a right click option to show you the xpath to reach the element (at least in chrome).
thanks for the reply @dave.tenny
in my case the items get autogenerated by the frontend framework
so copying the xpath only gives me a random id
any idea what the xpath would look like for my example? Sorry, I don't usually use xpath
Usually I can use xpath patterns to match the hierarchy of entities and find the anchor/button/input I'm looking for
does that support an "nth" argument?
I think the docstring mentioned something about a [n]
option in xpath
Dunno, would need to see the page, usually I start with the xpath that the debugger gives me and then generalize it with patterns if necessary.
(wildcards on path, etc)
//*id=ember8779[@""]
that's the browser xpath 🙂
unfortunately it's as correct as it's unhelpful
Maybe something like //a[@class='my-a-class']
or buttons/inputs/list elements, etc
and @class
is some distinguishing property on the element in question that you can predict in advance
Barring that, you can also call (api/get-source driver)
, tease out what you want with java regular expressions, then compose some element ID to click on, which I'm often forced to do in extreme cases.
I'm not good with css though, and not very good with xpath either, but I almost always use xpath with etaoin
haha i'd rather not 🙂
i tried the suggested xpath but it doesn't work. But that's probably because i can't xpath
this ended up working: (click-el driver (nth (query-all driver (el :search :search-results)) 6))
I opened an issue about it: https://github.com/igrishaev/etaoin/issues/154
Oh, since you're here though, and you seem to have more experience than me, @dave.tenny:
Any idea on how to get full-length screenshots?
'fraid not. I mostly (spit "/tmp/page.html" (api/get-source driver))
and debug on the html
On that fragment above though, you might hit it with something like //ul/li/a
unless you have other such matches on the page
or //ul/li[@class='search-result']/a
, or even omitting the 'a' entirely
oh, but I see you have multiple possible matches
in which case perhaps it's //ul/li[@class='search-result'][0]/a
or something like that, I definitely am not qualified to wing it
hm okay
thanks for the help!
Hi. Is there a way to flash a particular element like https://github.com/semperos/clj-webdriver/blob/508eb95cb6ad8a5838ff0772b2a5852dc802dde1/src/webdriver/core_element.clj#L62 ? Or... what is the etaoin way for testing a locator query to see if you have the right element? (It might not look like I'm here, but I do check periodically for responses)