iFrames ChromeFindElements example not working

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gtdalsanto
Pro Scripter
Posts: 51
Joined: Tue Oct 03, 2006 4:22 pm
Location: Akron, Ohio
Contact:

iFrames ChromeFindElements example not working

Post by gtdalsanto » Thu Jun 03, 2021 7:17 pm

I am running the sample script to test iframes using chrome. ChromeFindElements always comes back with nothing in the array.

My ChromeDriver.exe matches chrome version of ChromeDriver 91.0.4472.19 with chrome version of
Version 91.0.4472.77 .

I am executing the chromeIframe example from the command help:
Let>CHROMEDRIVER_EXE=%SCRIPT_DIR%\ChromeDriver\chromedriver.exe
ChromeStart>session_id
ChromeNavigate>session_id,url,https://www.mjtnet.com/contact.htm
ChromeFindElements>session_id,xpath,//iframe[@src='/contact-form/formpage.html'],elements

Everything works fine until i run the ChromeFindElements command which brings back nothing (count=0) on the ChromeFindElements array.

Do i have something wrong with the syntax for the ChromeFindElements command? It gets a session_id and navigates to the mjtnet.com contact page with no problem. Also in console mode for chromedriver.exe, i got the following error dump which not sure if any of the USB errors is pertinent. Possibly the second error that says "Passthrough is not supported, GL is disabled" could be what is wrong.

ChromeDriver.exe console mode:

Starting ChromeDriver 91.0.4472.19 (1bf021f248676a0b2ab3ee0561d83a59e424c23e-refs/branch-heads/4472@{#288}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/secur ... iderations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

DevTools listening on ws://127.0.0.1:64700/devtools/browser/253ad184-2a30-4955-a9db-da1793ff1270
[19932:11084:0603/144515.256:ERROR:device_event_log_impl.cc(214)] [14:45:15.257] USB: usb_device_handle_win.cc:1058 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[18880:13120:0603/144716.092:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is disabled
[19932:11084:0603/150255.060:ERROR:device_event_log_impl.cc(214)] [15:02:55.057] USB: usb_service_win.cc:258 Failed to get device driver name: Element not found. (0x490)

Hopefully you can point me into the correct direction. thanks.
Gary
Gary T. DalSanto
Inventive Software Designs, LLC
[email protected]

gtdalsanto
Pro Scripter
Posts: 51
Joined: Tue Oct 03, 2006 4:22 pm
Location: Akron, Ohio
Contact:

Re: iFrames ChromeFindElements example not working

Post by gtdalsanto » Thu Jun 03, 2021 9:08 pm

After further review and looking at the page source by using chrome developer tools, i noticed that the ChromeFindElements session_id and value were incorrect in the help example. The value needed an additional page identifier added (?001) at the end of the formpage.html value statement. The session_id variable was sessionid on the ChromeFindElements line in the help example which caused a json error.

Running it with the following changes it worked perfectly. Below shows the changes in bold that i made.

Let>CHROMEDRIVER_EXE=%SCRIPT_DIR%\ChromeDriver\chromedriver.exe
ChromeStart>session_id
ChromeNavigate>session_id,url,https://www.mjtnet.com/contact.htm
ChromeFindElements>session_id,xpath,//iframe[@src='/contact-form/formpage.html?001'],elements

//switch to the first frame (the one with the fields)
ChromeSwitchFrame>session_id,element,elements_1,res
//now anything we do is inside that frame so we should be able to get the name field and enter something
ChromeFindElements>session_id,id,name,inputs
ChromeSetElementValue>session_id,inputs_1,john doe
Gary T. DalSanto
Inventive Software Designs, LLC
[email protected]

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