Jump to content

Recommended Posts

Posted

IE is about to be shutting down and in my company, every Website that can't be run on Mozilla will be run on Edge on IE mode. So i gotta find a way to manipulate Edge on IE mode and that's not possible with IE UDF unfortunatly

Posted

Hi again,

I think i'm getting closer !

I'm trying with IERDriverServer :

_WD_Option('Driver', @ScriptDir & '\include\' & (@Compiled ? '' : 'Exe_externe\') & 'IEDriverServer.exe')
_WD_Option('DriverParams', '--log trace ')
_WD_Option('Port', 5555)
Local $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"se:ieOptions": { "ie.edgechromium":true, "ie.edgepath":"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"}}}}'

But now i get this error in the console :

  Quote

_WD_CreateSession: {
    "value" :
    {
        "error" : "session not created",
        "message" : "Unexpected error launching Internet Explorer. CreateProcess() failed for edge with the following command: msedge.exe --ie-mode-force --internet-explorer-integration=iemode --user-data-dir=C:\\Users\\JOUGLE~1\\AppData\\Local\\Temp\\IEDriver-0a0bc4ed-54ca-4b71-84bf-7d2c4ebcf5c9 --no-first-run --no-service-autorun --disable-sync --disable-features=msImplicitSignin http://localhost:5555/",
        "stacktrace" : ""
    }
}

Expand  

I have no idea what to think about this error message, if anyone has an idea i would be grateful !

Posted
  Quote

Where did you come up with these?

Expand  

From reading forums and example in Java, i knew i had to edit those 2 options in order to get EDGE run instead of IE, i just didn't know how to do it in Autoit. Then while i was trying random way to do it, i got the structure in the console :

_WD_CreateSession: {
    "value" :Unexpected error launching Internet Explorer. CreateProcess() failed for edge with the following command 
    {
        "capabilities" : 
        {
            "acceptInsecureCerts" : false,
            "browserName" : "internet explorer",
            "browserVersion" : "11",
            "pageLoadStrategy" : "normal",
            "platformName" : "windows",
            "proxy" : {},
            "se:ieOptions" : 
            {
                "browserAttachTimeout" : 0,
                "elementScrollBehavior" : 0,
                "enablePersistentHover" : true,
                "ie.browserCommandLineSwitches" : "",
                "ie.edgechromium" : false,
                "ie.edgepath" : "",
                "ie.ensureCleanSession" : false,
                "ie.fileUploadDialogTimeout" : 3000,
                "ie.forceCreateProcessApi" : false,
                "ignoreProtectedModeSettings" : false,
                "ignoreZoomSetting" : false,
                "initialBrowserUrl" : "http://localhost:5555/",
                "nativeEvents" : true,
                "requireWindowFocus" : false
            },
            "setWindowRect" : true,
            "strictFileInteractability" : false,
            "timeouts" : 
            {
                "implicit" : 0,
                "pageLoad" : 300000,
                "script" : 30000
            },
            "unhandledPromptBehavior" : "dismiss and notify"
        },
        "sessionId" : "6d10a485-493d-4176-ac62-3e5f29447b50"
    }
}

From then i managed to open Edge by edited those 2 options as mentioned above.

 

It's now working, i had to double the blackslah of my edge path option. The correct code is :

_WD_Option('Driver', @ScriptDir & '\include\' & (@Compiled ? '' : 'Exe_externe\') & 'IEDriverServer.exe')
    _WD_Option('DriverParams', '--log trace ')
    _WD_Option('Port', 5555)
    Local $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": { "se:ieOptions" : { "ie.edgepath":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", "ie.edgechromium":true, "ignoreProtectedModeSettings":true }}}}'

    $iWDPid = _WD_Startup()
    $sWDSession = _WD_CreateSession($sDesiredCapabilities)

Thanks for the help !

Posted

Going forward on my project to pilote an IE mode Edge browser, i got another problem. It looks like WebDriver functions are not working well with IEDriverServer and even some of them are considered as unknown command.

See bellow, the result when i'm trying to locate an element by name :

_WD_GetElementByName($sWDSession, "nir") ==> Console :

__WD_Post ==> Webdriver Exception: {
	"value" : 
	{
		"error" : "invalid selector",
		"message" : "Unable to locate an element with the xpath expression //*[@name=\"nir\"] because of the following error:\nTypeError"
    	"stacktrace" : ""
    }
}

When i'm trying to edit an input :

_WD_SetElementValue($sWDSession, $hNir, $sNir) ==> console :
 
 _WD_ElementAction ==> Unknown Command: {
    "value" : 
    {
        "error" : "unknown command",
        "message" : "Command not found: POST /session/b7e28baf-19bf-43d3-8ff2-7cfa79c51a14/element/value",
        "stacktrace" : ""
    }
}

 

Any idea ?

Posted

@KerasI'm not sure why it wouldn't like that xpath since AFAIK the other major webdrivers all accept it without any issues. If you take a look at the code for _WD_GetElementByName, you will see that it is just a wrapper for _WD_FindElement. You will need to experiment to find an xpath that works with this driver and then report back.

I'm not sure what's happening as far as _WD_SetElementValue. Does this happen with all webdrivers or just IEDriver? What are the contents of $hNir and $sNir?

Posted

@Danp2I tried with CSSSelector strategy instead of Xpath and it worked for _WD_FindElement. I'll have to experiment a bit more to find out why it haven't worked with Xpath strategy.

Regarding _WD_SetElementValue, it was maybe not working because $hNir was the handle returned by _WD_GetElementByName which resulted into an error. With the CSSSelector method, _WD_SelEmentValue is working a little bit. It sets the value on the input, but it does it really slowly, like 1 character each 2 secondes and it end up with a timed out :

__WD_Post: URL=HTTP://127.0.0.1:5555/session/156e8b6e-f483-4f52-9606-dd4370257d1e/element/6c4decdb-bc31-4f8a-9262-716d440be3a3/value; $sData={"id":"6c4decdb-bc31-4f8a-9262-716d440be3a3", "text":"1971159606364"}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_ElementAction: WinHTTP request timed out before Webdriver...
_WD_ElementAction ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_SetElementValue ==> Send / Recv error

 

Posted

@Danp2I hope so. There is still the message :

"Turn off remote debugging to open this site in IE mode otherwise it might not work as expected."

I saw there that they had once the same issue on IE driver and it got patched. I'll see if i can ask for the same for MSEdge driver 🙏.

Posted

Fixed the (very very) slow part of InternetExplorerDriver WebDriver by replacing IEDriverServer.exe (switched from x64 version to x32 version). Everything is good now !

Thanks for help !

Posted
  On 4/26/2022 at 9:40 AM, Keras said:

Fixed the (very very) slow part of InternetExplorerDriver WebDriver by replacing IEDriverServer.exe (switched from x64 version to x32 version). Everything is good now !

Expand  

Please share to us full working example.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

@mLipok Yep :
 

#include "include\wd_core.au3"
#include "include\wd_helper.au3"

Global $sUrlExample = "https://getbootstrap.com/docs/4.0/components/forms/"

_Setup_IEDriver()

Global $sWDSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sWDSession, $sUrlExemple)
_WD_LoadWait($sWDSession)
_form_example("Test@test.fr", "azerty123456")

Func _form_example($sEmail, $sPassword)
    Local $sEmailInput = _WD_GetElementByID($sWDSession, "exampleInputEmail1")
    _WD_ElementAction($sWDSession, $sEmailInput, "VALUE", $sEmail)

    Local $sPasswordInput = _WD_GetElementByID($sWDSession, "exampleInputPassword1")
    _WD_ElementAction($sWDSession, $sPasswordInput, "VALUE", $sPassword)

    Local $sCheckBox = _WD_GetElementByID($sWDSession, "exampleCheck1")
    _WD_ElementAction($sWDSession, $sCheckBox, "click")
EndFunc

Func _Setup_IEDriver()
    _WD_Option('Driver', @ScriptDir & '\include\' & (@Compiled ? '' : 'Exe_externe\') & 'IEDriverServer.exe')
    _WD_Option('DriverParams', '--log trace ')
    _WD_Option('Port', 5555)
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": { "se:ieOptions" : {"ie.edgepath":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", "ie.edgechromium":true, "ignoreProtectedModeSettings":true, "args" : ["start-maximized", "disable-infobars"]}}}}'
    _WD_Startup()
EndFunc   ;==>_Setup_IEDriver

OS : Windows 10

Autoit version : 3.3.16.0

Webdriver UDF : 0.8.1

WinHttp : 1.6.4.2

Driver : IE Driver Server version 4.0.0.0 (32 Bit)

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 05/02/2022
Posted (edited)

I got a _WD_ElementAction 'clear' that is not working on Edge with IEDriver but is working on Mozilla with geckodriver (exact same input and code) :
 

Local $sEmailInput = _WD_GetElementByID($sWDSession, "exampleInputEmail1")
_WD_ElementAction($sWDSession, $sEmailInput, "VALUE", $sEmail)
_WD_ElementAction($sWDSession, $sEmailInput, "clear")

Output : error : 10 ($_WD_ERROR_Exception)

So i'm looking to send keyboard command into the input in order to send "CTRL+a" then "delete" and i saw some example in this forum, so i tried this to first send "enter" keyboard command (here is the list😞

Local $sEmailInput = _WD_GetElementByID($sWDSession, "exampleInputEmail1")
_WD_ElementAction($sWDSession, $sEmailInput, "VALUE", $sEmail)
_WD_ElementAction($sWDSession, $sEmailInput, "value", "\uE007")

The result is "\uE007" written into the input, what i'm missing ?

Edited by Keras
Posted (edited)

I went for something proper than sending keyboard command. It works both with IEDriver and Geckodriver :

Local $sElement = _WD_GetElementByName($oSelf.sWDSession, $sQuery)
Local $sJsonElement = '{"element-6066-11e4-a52e-4f735466cecf":"' & $sElement & '"}'
_WD_ExecuteScript($oSelf.sWDSession, "arguments[0].value = '' ;", $sJsonElement)

 

Edited by Keras
Posted

How did you declare 

$oSelf

 

?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 5/5/2022 at 11:59 AM, Keras said:
Local $sElement = _WD_GetElementByName($oSelf.sWDSession, $sQuery)
Local $sJsonElement = '{"element-6066-11e4-a52e-4f735466cecf":"' & $sElement & '"}'
_WD_ExecuteScript($oSelf.sWDSession, "arguments[0].value = '' ;", $sJsonElement)

 

Expand  

I tested this code with chromedriver to set a value of an element and this is superfast compared to _WD_ElementAction, $sSession, $sElement, "value", $sValue).
However, it doesn't work if $sValue contains a @CR or @LF character.  Any suggestion to allow these characters?

Posted (edited)
  On 5/5/2022 at 2:37 PM, Danp2 said:

Can you test this scenario with _WD_SetElementValue using an $iStyle of $_WD_OPTION_Advanced?

Expand  

My $sValue looks like this:
 

<table style="border-collapse: collapse; border-style: solid; border-color: black; text-align: center; font-size: 110%" cellspacing="0" cellpadding="0" width=700 border="1">
<tbody><tr bgcolor="FFFFCC" height=30>
<td style="vertical-align: middle" width=90><b>일자</b></td>
<td style="vertical-align: middle" width=50><b>요일</b></td>
<td style="vertical-align: middle" width=70><b>코스</b></td>
<td style="vertical-align: middle" width=50><b>티타임</b></td>
<td style="vertical-align: middle" width=80><b>예약자</b></td>
<td style="vertical-align: middle" width=300><b>참가자</b></td></tr>
<tr bgcolor=white height=30>
<td style="vertical-align: middle" rowspan=1><a href=????><u>2022.05.10</u></a></td>
<td style="vertical-align: middle" rowspan=1></td>
<td style="vertical-align: middle">IN </td>
<td style="vertical-align: middle">13:00</td>
<td style="vertical-align: middle">박정창  </td>
<td style="vertical-align: middle; padding-left: 7px" align="left">취소</td></tr>
<tr bgcolor=FFFFCC height=30>
<td style="vertical-align: middle" rowspan=1><a href=????><u>2022.05.11</u></a></td>
<td style="vertical-align: middle" rowspan=1></td>
<td style="vertical-align: middle">IN </td>
<td style="vertical-align: middle">13:07</td>
<td style="vertical-align: middle">????</td>
<td style="vertical-align: middle; padding-left: 7px" align="left"><b><span style="color: blue;">????</span></b></td></tr>
<tr bgcolor=white height=30>
<td style="vertical-align: middle" rowspan=1><a href=????><u>2022.05.17</u></a></td>
<td style="vertical-align: middle" rowspan=1></td>
<td style="vertical-align: middle">IN </td>
<td style="vertical-align: middle">13:28</td>
<td style="vertical-align: middle">???  </td>
<td style="vertical-align: middle; padding-left: 7px" align="left">????</td></tr>
<tr bgcolor=FFFFCC height=30>
<td style="vertical-align: middle" rowspan=1><a href=????><u>2022.05.18</u></a></td>
<td style="vertical-align: middle" rowspan=1></td>
<td style="vertical-align: middle">IN </td>
<td style="vertical-align: middle">13:28</td>
<td style="vertical-align: middle">???  </td>
<td style="vertical-align: middle; padding-left: 7px" align="left">????</td></tr>
<tr bgcolor=white height=30>
<td style="vertical-align: middle" rowspan=1><a href=????><u>2022.05.19</u></a></td>
<td style="vertical-align: middle" rowspan=1></td>
<td style="vertical-align: middle">서 OUT</td>
<td style="vertical-align: middle">13:28</td>
<td style="vertical-align: middle">???  </td>
<td style="vertical-align: middle; padding-left: 7px" align="left">????</td></tr>
</tbody></table>

I tested this with @Keras code as follows and it works fine.
 

$sValue = StringReplace($sValue, @CRLF, "")
Local $sJsonElement = '{"element-6066-11e4-a52e-4f735466cecf": "' & $sElement & '"}'
_WD_ExecuteScript($sSession, "arguments[0].value = '" & $sValue & "'; ", $sJsonElement)

_WD_SetElementValue using an $iStyle of $_WD_OPTION_Advanced works with $sValue containing @CRLF, but it can't accomodate double quotation. The following code works fine.
 

$sValue = StringReplace($sValue, '"', "'")
_WD_SetElementValue($sSession, $sElement, $sValue, $_WD_OPTION_Advanced)

I am currently using the following code, borrowed from you, and I will have to stick with this for the time being.
 

_WD_ElementAction($sSession, $sElement, "click")
ClipPut($sValue)
Sleep(100)

$sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE009"},'
$sAction &= '{"type": "pause", "duration": 500},'
$sAction &= '{"type": "keyDown", "value": "v"}, {"type": "keyUp", "value": "v"},'
$sAction &= '{"type": "keyUp", "value": "\uE009"}]}]}'
_WD_Action($sSession, "actions", $sAction)

 

Edited by CYCho
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...