0

Is it possible to get the text inside this button which is "Confirm" and click on it?

enter image description here

Also, I learned that we use .click() to click on elements

Because the Classes changes frequently, so how to click this button according to the Text which is Confirm.

This is the relevant button code which is a span :

<span jsslot="" class="CwaK9"><span class="RveJvd snByac">Confirm</span></span>

Here is the full button code :

<div class="yKBrKe" jsname="hWDCP">
  <div role="button" class="U26fgb O0WRkf zZhnYe C0oVfc Zrq4w NTcbm RHAxtb M9Bg4d" jscontroller="VXdfxd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue; 
    focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd;" jsshadow="" jsname="UjXomb" tabindex="0">
    <div class="Vwe4Vb MbhUzd" jsname="ksKsZd"></div>
    <div class="ZFr60d CeoRYc"></div><span jsslot="" class="CwaK9">
    <span class="RveJvd snByac">Confirm</span></span>
  </div>
</div>
Dani
  • 85
  • 2
  • 8
  • Wow. So you have a screwed up class system, and because of that you want to screw up the rest? Why not use the `name` or `id` attribute? – KIKO Software Dec 07 '20 at 09:08
  • https://stackoverflow.com/questions/3813294/how-to-get-element-by-innertext This question has been answered before – Jasper Chesselet Dec 07 '20 at 09:09
  • How can I ? im very new to js – Dani Dec 07 '20 at 09:10
  • 1
    This looks like encrypted code, well, at least the classes are. I would start to learn normal Javascript before attempting to interfere with something like this. – KIKO Software Dec 07 '20 at 09:13
  • @KIKOSoftware Sir, the Text is always constant. Can we do something with the text – Dani Dec 07 '20 at 09:16
  • 1
    You can do something with the text, but that's not how you would normally do this. It also "complicated", more complicated than it needs to be. Best to attach another click even to the `
    – KIKO Software Dec 07 '20 at 09:21
  • 1
    You could use `document.querySelector('[role="button"]')` to find all elements with `role=button`. Then test all it's children for the word Confirm, then click that button. [Here's a Fiddle](https://jsfiddle.net/rv2dL4h8/1/) – Michel Dec 07 '20 at 09:45

0 Answers0