How to Click a Google Chrome Xpath?

Hi folks,

I'm using the Click Google Chrome Link action, trying to click the Xpath element at

/html/body/div[36]/div/div/div/div[1]/div[2]/div[1]/div[1]/div/div/div/div[3]/div/div/div[4]/table/tbody/tr/td[2]/table/tbody/tr[2]/td/div/div/div[4]/table/tbody/tr/td[6]/div/div[1]/div/div[2]

(If you use Gmail, just open a compose window and this Path should reference the three-vertical-dots menu at the bottom right of the compose window.)

I got the Xpath in Chrome by doing Inspect Element > Copy Full Xpath.

Why not just use Inspect > Copy Xpath? Because there's an ID in there which changes for every new compose window. Only the full Xpath is the same from one compose window to the next.

I can't get it working! It says can't find Xpath. Help?

Yikes, I'm not sure I've ever seen such a dynamic page source code. Anyway, I love clicking links directly but at this point I'd probably use the "Click at Found Image" action and move on with my next task :slight_smile:

I tried using JavaScript with querySelector, and I could get a reference to the proper element, but it would NOT respond to the click() method.

I also tried several other buttons/link in that Compose window, and none of them would respond to a click() method.

So my guess is that Google has done some black magic to prevent JavaScript insertion of a click event.

Given that, I have to agree with @vincent_ardern that using a found image might be your best bet. I would use the "Send" button with an offset to the 3-dot "More options" button.

Good luck and let us know if you find a solution.

Thank you very much! How do I retrieve the Send button image?

Use the macOS screen capture tool.

That's very sexy. And how do I find the offset to the 3 vertical dots?

Use the same macOS tool to measure from center of "Send" button to center of "More options" button.

Whoahhhhhhhh

What an amazing product is Keyboard Maestro. Licensing now...!

1 Like

I have maybe the seame problem with google ads menu.
The xpath I can find for the link menu of Campaign button" is /html/body/div[2]/root/div/div[1]/div/div/div[3]/awsm-skinny-nav/div/div/div[2]/awsm-skinny-nav-item[1]/a/material-ripple

But now success with clic safari link and xpath.
Can someone suggest whot to solve? I don't know JS unfortunately

Thanks and sorry if I am a bit out of topic

Right click on any element you want xpath for and click on "Inspect Element" and then again inside the Inspector, right click on element and click on "Copy Xpath ".
...
From Chrome :

  1. Right click "inspect" on the item you are trying to find the xpath .
  2. Right click on the highlighted area on the console.
  3. Go to Copy xpath .

If you're new to the MacOS screen capture tool be aware, while using "Shift+Cmd+4" and using the crosshair to select the screen area to capture, you can press "Control" before letting up on the mouse to save the screen capture directly to the system clipboard. This is a real time-saver working with KM "Found Image" actions.

2 Likes

also remember to enable in Safari: Develop > Allow JavasCript from Apple Events