chromedriver.exe once and for all

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

chromedriver.exe once and for all

Post by mightycpa » Thu Apr 15, 2021 3:42 pm

Yesterday, I encountered yet another problem with chromedriver. Let's see if we can figure it out.

First off, I got this error:

Image

Then I found this link that tells me what to do about it:

https://help.mjtnet.com/article/344-chr ... nary-names

So I did it. Here's proof:

https://www.canva.com/design/DAEbvmQjq_ ... hsharelink

Now the script is almost ready. Let's watch what happens:

https://app.vidjack.com/share/3154

Still doesn't work. I've already tried rebooting, that doesn't help. What's next?
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: chromedriver.exe once and for all

Post by Grovkillen » Thu Apr 15, 2021 3:59 pm

What's on line 35?
Let>ME=%Script%

Running: 15.0.27
version history

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: chromedriver.exe once and for all

Post by mightycpa » Thu Apr 15, 2021 4:06 pm

Hi,

It was from your code yesterday. To be clear, I get that error twice. Once on line 35, once on line 36:

Code: Select all

//CAUSES OF ERROR:
//If you get a network failure it's probably due to the wait on line 46 being too small.
//If you get slider overshooting it's probably due to the find image pos tolerance on line 41 being not strict enough.
IfNotFileExists>%SCRIPT_DIR%\needle.bmp
  ExportData>BUTTON_IMAGE.BMP_DATA,%SCRIPT_DIR%\needle.bmp
Endif>
Let>WINDOW_TO_LOOK_IN=GeeTest CAPTCHA | Demo - Google Chrome
Let>URL_TO_DEMO=https://www.geetest.com/en/demo
Let>BUTTON_CAPTION=Slide CAPTCHA
Let>VERIFY_CLASS=geetest_radar_tip
Let>CANVAS_DIRTY_CLASS=geetest_canvas_bg
Let>CANVAS_CLEAN_CLASS=geetest_canvas_fullbg
Let>SLIDER_TRACK_CLASS=geetest_slider_track
Let>SLIDER_BUTTON_CLASS=geetest_slider_button
Let>MISMATCH_TOL=50
Let>MISMATCH_STREAK=35
Let>MOUSE_SLIDE_TWEAK_PIXELS=-2
Let>CHROMEDRIVER_EXE=%SCRIPT_DIR%\chromedriver.exe
Let>LOOP_max=5
Let>LOOP_k=0
Repeat>LOOP_k
  Let>LOOP_k=LOOP_k+1
  GoSub>THE_CAPTCHA_ROUTINE
Until>LOOP_k=LOOP_max
SRT>THE_CAPTCHA_ROUTINE
  ChromeStart>SessionID
  ChromeNavigate>SessionID,url,%URL_TO_DEMO%
  ChromeExecute>SessionID,[...document.getElementsByTagName("button")].map(button => { if (button.textContent === "%BUTTON_CAPTION%") { button.click() } })
 //an element with id="wait" will get a style of "display: none;" when the captcha is loaded... could be used instead of wait
  Wait>5
  ChromeExecute>SessionID,document.querySelector(".%VERIFY_CLASS%").click()
  Wait>3
  LabelToVar>compare_canvas,JS_CODE,1,0,*/
  ChromeExecute>SessionID,JS_CODE
  
  /**** JSON errors occur here:  *******/
  
  ChromeFindElements>SessionID,id,get_pixels_to_travel,element
  ChromeGetElementData>SessionID,element_1,text,PIXELS_TO_MOVE_MOUSE
   
  /**** end 35 and 36  *******/ 
  
 
  If>PIXELS_TO_MOVE_MOUSE>0

FindImagePos>%SCRIPT_DIR%\needle.bmp,WINDOW:%WINDOW_TO_LOOK_IN%,0.7,1,MOUSE_X_START,MOUSE_Y_START,NumFound,CCOEFF
    If>NumFound>0
      Let>SLIDE_TO_END_POSITION=PIXELS_TO_MOVE_MOUSE+MOUSE_SLIDE_TWEAK_PIXELS
      MouseMove>MOUSE_X_START_0,MOUSE_Y_START_0
      LDown
      Wait>0.5
      Let>k=0
      Repeat>k
        Let>k=k+1
        Let>MOUSE_NEW_POSITION=MOUSE_X_START_0+k
        MouseMove>MOUSE_NEW_POSITION,MOUSE_Y_START_0
        If>k>SLIDE_TO_END_POSITION
          Let>k=SLIDE_TO_END_POSITION
        Endif>
      Until>k=SLIDE_TO_END_POSITION
      Wait>0.5
      Lup
    Endif
    Wait>3
  Endif>
  ChromeQuit>SessionID
END>THE_CAPTCHA_ROUTINE
/*
compare_canvas:
let sliderButton = document.querySelector(".%SLIDER_BUTTON_CLASS%");
let canvasFrame = document.querySelector(".%CANVAS_DIRTY_CLASS%");
let dirtyCanvas = document.querySelector(".%CANVAS_DIRTY_CLASS%").getContext("2d");
let dirtyPixels = dirtyCanvas.getImageData(0, 0, canvasFrame.width, canvasFrame.height);
let dirtyPixel = dirtyPixels.data;
let cleanCanvas = document.querySelector(".%CANVAS_CLEAN_CLASS%").getContext("2d");
let cleanPixels = cleanCanvas.getImageData(0, 0, canvasFrame.width, canvasFrame.height);
let cleanPixel = cleanPixels.data;
let misMatchTolerance = %MISMATCH_TOL%;
let misMatchCountWanted = %MISMATCH_STREAK%;
let misMatchCount = 0;
sliderButton.scrollIntoView({
          behavior: 'auto',
          block: 'center',
          inline: 'center'
      });
for (let i = 0; i < dirtyPixel.length; i += 4) {
    let dirtyRGBA = dirtyPixel[i] + dirtyPixel[i+1] + dirtyPixel[i+2] + dirtyPixel[i+3];
    let cleanRGBA = cleanPixel[i] + cleanPixel[i+1] + cleanPixel[i+2] + cleanPixel[i+3];
    let diffCheck = Math.abs(dirtyRGBA - cleanRGBA);
    if (diffCheck > misMatchTolerance) {
        misMatchCount++;
    } else {
        misMatchCount = 0;
    }
    if (misMatchCount === misMatchCountWanted) {
        let pixelNumber = Math.floor(i / 4 - misMatchCountWanted);
        let offsetX = pixelNumber % canvasFrame.width;
        let offsetY = ( pixelNumber - offsetX ) / canvasFrame.width;
        dirtyCanvas.fillStyle = "rgb(56,255,3)";
        dirtyCanvas.fillRect( offsetX, 0, 3, canvasFrame.height );
        dirtyCanvas.fillRect( 0, offsetY, canvasFrame.width, 3 );
        let dumpElement = document.createElement("div");
        dumpElement.id = "get_pixels_to_travel";
        dumpElement.innerText = offsetX;
        document.body.appendChild(dumpElement);
        break;
    }
}
*/
/*
BUTTON_IMAGE.BMP_DATA:
424DDA05000000000000360000002800000013000000130000000100200000000000A405000000000000000000000000000000000000F7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F
7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F7FFF7F7F8FFF7F8F8FFF7F7F8FFF7F7F8FFF7F8F8FFF7F7F7FFF8F8F7FFF7F7F8FFF7F7F7FFF7F7F7FFF7F7F7FFF7
F7F7FFF7F8F7FFF7F7F8FFF7F8F7FFF7F7F7FFF7F8F7FFF7F7F8FFF8F8F8FFF8F8F8FF7ECFA6FF10C368FF77E2ABFFF8F8F8FFF8F8F8FFF8F8F8FFF8F8F8FF7ECFA6FF10C368FF77E2ABFFF8F8F8FFF8F8F8FFF8F8F8FFF8F8F8FF7ECFA6FF10C368FF77E2ABFFF8F8F8FFF8F8F8FF12AB5CFF05C562FF06D369FFF8F8F8FFF
8F8F8FFF8F8F8FFF8F8F8FF12AB5CFF05C562FF06D369FFF8F8F8FFF8F8F8FFF8F8F8FFF8F8F8FF12AB5CFF05C562FF06D369FFF8F8F8FFF8F8F8FF0FAA5AFF05C562FF00D266FFF8F8F8FFF8F8F8FFF8F8F8FFF8F8F8FF0FAA5AFF05C562FF00D266FFF8F8F8FFF8F8F8FFF8F8F8FFF8F8F8FF0FAA5AFF05C562FF00D266FF
F8F8F8FFF8F8F8FF0FAA5AFF05C562FF00D266FFF8F8F8FFF8F8F8FFF9F8F8FFF8F8F8FF0FAA5AFF05C562FF00D266FFF8F8F8FFF9F8F8FFF8F8F8FFF8F8F8FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9F
FF9F9F9FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9
FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFF9F9F9FFF9F9F9FFF9F9F9FFF9F9F9FF0FAA5AFF05C562FF00D266FFFAFAF
9FFFAFAFAFF0FAA5AFF05C562FF00D266FFF9FAFAFFFAF9F9FFF9FAFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFF9F9FAFFFAFAFAFFFAFAFAFFFAF9F9FF0FAA5AFF05C562FF00D266FFFAFAFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFFAFAFAFFFAFAFAFFFAFAFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFFAFAFAFFFAFA
FAFFFAFAFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFFAFAFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFFAFAFAFFFAFAFAFFFAFAFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFFAFAFAFFFAFAFAFFFAFAFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFFAFAFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFFAFAFAFFFAFAFAFFFAF
AFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFFAFAFAFFFAFAFAFFFAFAFAFFFAFAFAFF0FAA5AFF05C562FF00D266FFFBFBFBFFFBFAFAFF0FAA5AFF05C562FF00D266FFFAFBFBFFFBFBFBFFFBFAFAFFFBFBFBFF0FAA5AFF05C562FF00D266FFFAFBFAFFFBFBFBFFFAFAFBFFFAFAFBFF0FAA5AFF05C562FF00D266FFFBFBFBFFFB
FBFBFF0FA95AFF06C161FF01CE65FFFBFBFBFFFBFBFBFFFBFBFBFFFBFBFBFF0FA95AFF06C161FF01CE65FFFBFBFBFFFBFBFBFFFBFBFBFFFBFBFBFF0FA95AFF06C161FF01CE65FFFBFBFBFFFBFBFBFF14A45AFF0BB45DFF0EBF64FFFBFBFBFFFBFBFBFFFBFBFBFFFBFBFBFF14A45AFF0BB45DFF0EBF64FFFBFBFBFFFBFBFBFFF
BFBFBFFFBFBFBFF14A45AFF0BB45DFF0EBF64FFFBFBFBFFFBFBFBFF82CAA5FF1CA760FF80CFA7FFFBFBFBFFFBFBFBFFFBFBFBFFFBFBFBFF82CAA5FF1CA760FF80CFA7FFFBFBFBFFFBFBFBFFFBFBFBFFFBFBFBFF82CAA5FF1CA760FF80CFA7FF
*/
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: chromedriver.exe once and for all

Post by Grovkillen » Thu Apr 15, 2021 6:07 pm

Well that means that the script wasn't able to create that element... did you make sure it's not trying to add a new element with an already existing one in the DOM?
Let>ME=%Script%

Running: 15.0.27
version history

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: chromedriver.exe once and for all

Post by mightycpa » Thu Apr 15, 2021 6:30 pm

:D

I wouldn't know how. That said, I'm using your code verbatim, and the browser is completely closed when I begin. So I assume that there is no document to begin with.

If you take a look at the short video where I do the recommended MJTNET script, I don't know what that's supposed to look like, but I'm pretty sure it isn't supposed to look like what I see. It doesn't seem to be able to navigate anywhere. My take on it is that nothing is being created when the session starts, and as a result, no steps beyond that will work.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: chromedriver.exe once and for all

Post by Grovkillen » Thu Apr 15, 2021 6:51 pm

Aren't the browser opening when you get to the Chrome start command?
Let>ME=%Script%

Running: 15.0.27
version history

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: chromedriver.exe once and for all

Post by mightycpa » Thu Apr 15, 2021 7:10 pm

It opens, yes, but it doesn't go anywhere. You can watch it, and see how it doesn't reach an address?

FYI, I cut out a lot of the middle to make it much shorter, and then I noticed the "crashed" part when I moved my mouse. I've also cut out the JSON errors on the end.

Image
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: chromedriver.exe once and for all

Post by Grovkillen » Thu Apr 15, 2021 7:25 pm

Try running this from the editor, make sure you save it first and have the chromedriver.exe in the same folder as the .scp file.

Code: Select all

Let>CHROMEDRIVER_EXE=%SCRIPT_DIR%\chromedriver.exe
ChromeStart>SessionID
ChromeNavigate>SessionID,url,https://www.google.com
Let>ME=%Script%

Running: 15.0.27
version history

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: chromedriver.exe once and for all

Post by mightycpa » Thu Apr 15, 2021 10:09 pm

It didn't work, acted just like the others. So I decided to step through it, and opened Task Manager/Processes to watch that.

Let> no problem detected.

ChromeStart> It struggled here. Chromedriver.exe launched once and chrome.exe launched at least 3 instances, and sometimes up to 5. Then the smaller chrome.exe's would terminate and then restart. After a while, all of the chrome.exe's terminated and the browser closed on its own. Interestingly, when I open chrome with my mouse, I get 9 chrome.exe's and then 1 terminates, leaving me with 8 processes. Long story short, I would conclude that chrome can't seem to launch.

After that step, a new variable was present in the Watch List:
SESSIONID=adaa5a5e49ed760d929e0d6188790533

Then I did:
ChromeNavigate> that did nothing, there was no activity in the CPU column; no errors, no nothing. It was probably over immediately.

The only other thing I noticed was that chrome is 64-bit, but the description for chromedriver.exe looks like 32 bit. The process is named chromedriver.exe *32

I wonder if that makes a difference. EDIT: this says it doesn't: https://bugs.chromium.org/p/chromedrive ... id=1797#c1
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: chromedriver.exe once and for all

Post by Grovkillen » Fri Apr 16, 2021 8:06 am

How many PIDs are active for the chromedriver.exe ?

Should be only one.

Code: Select all

GetProcessIDs>chromedriver.exe,PIDs
Let>ME=%Script%

Running: 15.0.27
version history

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: chromedriver.exe once and for all

Post by mightycpa » Fri Apr 16, 2021 1:53 pm

Good morning, yes, there's only one, regardless if I start with zero, or if I start with one.

I also watch it in Task Manager, because MS goes "dark" while chrome is trying to start up. When chrome finally closes, MS becomes active again.

Another movie to show you:
https://app.vidjack.com/share/3173
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: chromedriver.exe once and for all

Post by Grovkillen » Fri Apr 16, 2021 3:23 pm

Well, the editor do get "dark" once in a while during execution of commands so that's normal. Have you tried your code on another PC?
Let>ME=%Script%

Running: 15.0.27
version history

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: chromedriver.exe once and for all

Post by mightycpa » Fri Apr 16, 2021 4:04 pm

I have, but with an earlier version of MS. Two different licenses for two different owners. That didn't work either.

The major difference between what I've got and what you have is the OS. On the MS v.15 machine, it is Windows Server 2008R2. On the MS v.14 machine, it is Windows 10 Enterprise. Neither of those two can get just the basic chromedriver functionality to work. It's hard for me to imagine that's the difference, but there's nothing else I can think of to explain it.

Waiting for Marcus or Dorian to chime in with something other than "do the procedure found here: https://help.mjtnet.com/article/344-chr ... nary-names"
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: chromedriver.exe once and for all

Post by mightycpa » Fri Apr 16, 2021 4:59 pm

Grovkillen,

Can you send me a compiled version of your simple script? See if that works? I know it shouldn't work any better than script, but still, I'd like to check.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: chromedriver.exe once and for all

Post by Grovkillen » Fri Apr 16, 2021 6:52 pm

Let me get back to you later.
Let>ME=%Script%

Running: 15.0.27
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts