Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

Hey guys,

Trying to capture multiple screenshots of the same page with a delay in FF headless mode, I tumbled on your UDF. After playing a bit with it I honestly don't get how just to open a simple page. Here is a snippet of my quiet simple code that should just open Google, but instead it's starting an empty browser, immediately closing it and starts another empty then it stops here. If someone can just help me understand how it works :)

#include "wd_core.au3"
#include "wd_helper.au3"
_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--binary "C:\Program Files\Mozilla Firefox\firefox.exe" --log trace ')
_WD_Option('Port', 4444)
$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "http://www.google.com")

Many thanks in advance.

Link to comment
Share on other sites

@billou95 Please post the results from the Scite output panel. They should look like this --

_WDStartup: OS: WIN_10 WIN32_NT 18363 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.2.0.4
_WDStartup: WinHTTP:    1.6.4.2
_WDStartup: Driver: geckodriver.exe
_WDStartup: Params: --binary "C:\Program Files\Mozilla Firefox\firefox.exe" --log trace 
_WDStartup: Port:   4444
__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}
__WD_Post: StatusCode=200; ResponseText={"value":{"sessionId":"8df22810-21d6-4dca-8374-509490233a82","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"72.0.1","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:buildID":"20200107212822","moz:geckodriverVersion":"0.26.0","moz:headless":false,"moz:processID":33892,"moz:profile":"C:\\Users\\danpollak\\AppData\\Local\\Temp\\rust_mozprofileFOV9m9","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}
_WD_CreateSession: {"value":{"sessionId":"8df22810-21d6-4dca-8374-509490233a82","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"72.0.1","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:buildID":"20200107212822","moz:geckodriverVersion":"0.26.0","moz:headless":false,"moz:processID":33892,"moz:profile":"C:\\Users\\danpollak\\AppData\\Local\\Temp\\rust_mozprofileFOV9m9","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}
__WD_Post: URL=HTTP://127.0.0.1:4444/session/8df22810-21d6-4dca-8374-509490233a82/url; $sData={"url":"http://www.google.com"}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_Navigate: {"value":null}
+>06:55:40 AutoIt3.exe ended.rc:0
+>06:55:40 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 9.441

 

Link to comment
Share on other sites

Woops, sure here they are :

_WDStartup: OS: WIN_7 WIN32_NT 7601 Service Pack 1
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.2.0.4
_WDStartup: WinHTTP:    1.6.4.1
_WDStartup: Driver: geckodriver.exe
_WDStartup: Params: --binary "C:\Program Files\Mozilla Firefox\firefox.exe" --log trace 
_WDStartup: Port:   4444
__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}
__WD_Post: StatusCode=200; ResponseText={"value":{"sessionId":"16885323-f0d9-4064-89a7-1c18427387d7","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"60.9.0","moz:accessibilityChecks":false,"moz:geckodriverVersion":"0.26.0","moz:headless":false,"moz:processID":5072,"moz:profile":"C:\\Users\\PTGT05791\\AppData\\Local\\Temp\\rust_mozprofileX2oS4x","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"6.1","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
_WD_CreateSession: {"value":{"sessionId":"16885323-f0d9-4064-89a7-1c18427387d7","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"60.9.0","moz:accessibilityChecks":false,"moz:geckodriverVersion":"0.26.0","moz:headless":false,"moz:processID":5072,"moz:profile":"C:\\Users\\PTGT05791\\AppData\\Local\\Temp\\rust_mozprofileX2oS4x","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"6.1","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
__WD_Post: URL=HTTP://127.0.0.1:4444/session/16885323-f0d9-4064-89a7-1c18427387d7/url; $sData={"url":"http://www.google.com"}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_Navigate: {"value":null}
+>14:42:28 AutoIt3.exe ended.rc:0
+>14:42:28 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 8.299

 

Link to comment
Share on other sites

On 1/11/2020 at 5:23 AM, Danp2 said:

@crazycrash IMO, we aren't dealing with "most applications" here. We're dealing with a scripting / developer tool. As such, I would expect the person writing the script to take care of creating the destination directory before calling the function.

Also, have you checked to see if this is how other Autoit functions behave? FWIW, I tested InetGet, and it didn't create the missing directory.

You are of course fully correct. I dealt with it the proper way.

May I ask how you would go about changing an option in Firefox? For example:

fp = webdriver.FirefoxProfile()
fp.set_preference('permissions.default.image', 2)

Also, are you interested to replace the IELoadWait($oIE) function?

Best solution I found so far is to use js document.readyState until "complete" is returned.

Thanks

Edited by crazycrash
Link to comment
Share on other sites

20 minutes ago, crazycrash said:

May I ask how you would go about changing an option in Firefox? For example:

fp = webdriver.FirefoxProfile()
fp.set_preference('permissions.default.image', 2)

Look here and the example immediate below this for example of setting prefs.

Quote

Also, are you interested to replace the IELoadWait($oIE) function?

Hmmm... seems like you overlooked the existing _WD_LoadWait function. 😉

Link to comment
Share on other sites

On 1/17/2020 at 9:23 PM, Danp2 said:

Look here and the example immediate below this for example of setting prefs. 

Hmmm... seems like you overlooked the existing _WD_LoadWait function. 😉

Thanks, setting it in the capabilities did the trick. Fantastic.

_WD_LoadWait, perfect. I overlooked it, sorry. It wasn't part in the listed helper functions on the readme 😃

I have a case where I fail to download the image with _WD_DownloadFile, might you know why? It displays fine in the browser. Here is the example:

#include "wd_core.au3"
#include "wd_helper.au3"
$file = 'https://az534923.vo.msecnd.net/image.ashx?guid=59f690b7-0d5d-ef67-5389-9159e28f1034&w=-1&h=-1&rm=2&ac=10&mw=1024&mh=1024'
_WD_DownloadFile($file, @ScriptDir & "\test.jpg")

Instead of the image the function retrieves the "404 - File or directory not found" response.

_InetGet works fine:

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
$file = 'https://az534923.vo.msecnd.net/image.ashx?guid=59f690b7-0d5d-ef67-5389-9159e28f1034&w=-1&h=-1&rm=2&ac=10&mw=1024&mh=1024'
Local $sFilePath = @ScriptDir & "\testInetGet.jpg"
Local $hDownload = InetGet($file, $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
Do
    Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

Also a URL without https: in the URL returns an error, eg:

#include "wd_core.au3"
#include "wd_helper.au3"
$file = '//az534923.vo.msecnd.net/image.ashx?guid=59f690b7-0d5d-ef67-5389-9159e28f1034&w=-1&h=-1&rm=2&ac=10&mw=1024&mh=1024'
_WD_DownloadFile($file, @ScriptDir & "\test.jpg")

This also works fine with _InetGet

Thanks

Edited by crazycrash
Link to comment
Share on other sites

Quote

I have a case where I fail to download the image with _WD_DownloadFile, might you know why? 

Yes... you've found a bug in one of the internal UDF functions. I should have a fix out later today. Thanks for catching that!

5 hours ago, crazycrash said:

Also a URL without https: in the URL returns an error

Some of the internal functions use _WinHttpCrackUrl to parse the URL into its separate components. _WinHttpCrackUrl expects a full URL, including the scheme (HTTP / HTTPS). While I could try to "fix" this by prepending HTTP before the call to WinHttpCrackUrl, I feel that this is just masking the issue and could lead to additional problems. Bottom line is that I don't plan to change this behavior.

Link to comment
Share on other sites

Hi,

One of my scripts, which was working perfectly.. stopped suddenly and shows an error and returns null session id with the following desired capabilities. The Chrome.log file is attached to this post. Following is the response I am receiving. Can anyone please help. 

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": { "goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\User\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\", "disable-infobars"]}}}}'

 

I changed the user data dir to a new one and it is working fine now. 

Thanks.

chrome.log

Edited by PoojaKrishna
Problem fixed.
Link to comment
Share on other sites

Hi Danp2,

thanks for your work.

Im trying to figure out how exactly to use the WebDriver DUF.

Do i now need to learn codeing Java to use it like this one explains in his video?

All i wanna do is make this old script run with chrome, youd you please help me with it?

#RequireAdmin
#include <IE.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <Array.au3>
AutoItSetOption ( "TrayIconDebug", 1 )

#cs---------------------------------------  Auto Multi Email login  -----------------------------------------
;                                  _______
;    /\           _____  _____    |          _      _                   |      ______   _____
;   /  \   |    |   |   |     |   |____     | \    / |   /\   o |       |     |      | |       o |\  |
;  /----\  |    |   |   |     |   |      -- |  \  /  |  /--\  | |       |     |      | |  _ _  | | \ |
; /      \ |____|   |   |_____|   |_______  |   \/   | /    \ | |____   |____ |______| |_____| | |  \|
;
#ce----------------------------------------------------------------------------------------------------------



;--------------------  this is the GUI  ------------------------------------------------
$AutoEmail = GUICreate("Auto Email", 339, 125, @DesktopWidth, @DesktopHeight)
$aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "")
$aWin = WinGetPos($AutoEmail)
WinMove($AutoEmail, "", @DesktopWidth - $aWin[2] - 4, @DesktopHeight - $aWin[3] - $aTaskbar[3] - 4)

$Gmail = GUICtrlCreateButton("FreeBTC", 64, 16, 49, 41, $BS_ICON)
GUICtrlSetImage(-1, "C:\Users\iresolver\Downloads\gmail_icon.ico", 1)

$Hotmail = GUICtrlCreateButton("Hotmail", 223, 16, 49, 41, $BS_ICON)
GUICtrlSetImage(-1, "C:\Users\iresolver\Downloads\MSMail_icon.ico", 1)

$cCombo = GUICtrlCreateCombo("", 16, 72, 145, 25)
GUICtrlSetData(-1, "YourAccount1@gmail.com|YourAccount2@gmail.com|YourAccount3@gmail.com", "YourAccount1@gmail.com")

$cCombo2 = GUICtrlCreateCombo("", 176, 72, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "YourAccount1@hotmail.com|YourAccount2@hotmail.com|YourAccount3@hotmail.com", "YourAccount1@hotmail.com")

GUISetState(@SW_SHOW)
;--------------------  End of GUI  ------------------------------------------------------


While 1
If $Gmail Then Gmail ()
If $Hotmail Then Hotmail ()
WEnd


Func Gmail ()
Switch GUIGetMsg ()
        Case $GUI_EVENT_CLOSE
        Exit
        Case $Gmail
            Switch GUICtrlRead($cCombo)
        Case "YourAccount1@gmail.com"          ;change this to your G-Mail Account 1
                    gmail_Account1 ()          ;Don't change this line

        Case "YourAccount2@gmail.com"          ;change this to your G-Mail Account 2
                    gmail_Account2 ()          ;Don't change this line

        Case "YourAccount3@gmail.com"          ;change this to your G-Mail Account 3
                    gmail_Account3 ()          ;Don't change this line
            EndSwitch
            EndSwitch
EndFunc

Func Hotmail ()
    Switch GUIGetMsg ()
        Case $GUI_EVENT_CLOSE
        Exit

        Case $Hotmail
        Switch GUICtrlRead($cCombo2)

        Case "YourAccount1@hotmail.com"              ;change this to your Hotmail Account 1
                    Hotmail_Account1 ()              ;Don't change this

        Case "YourAccount2@hotmail.com"              ;change this to your Hotmail Account 2
                    Hotmail_Account2 ()              ;Don't change this line

        Case "YourAccount2@hotmail.com"              ;change this to your Hotmail Account 3
                    Hotmail_Account3 ()              ;Don't change this line
     EndSwitch
     EndSwitch

EndFunc

Func gmail_Account1 ()

Global $oIE =_IECreate ("http://www.gmail.com")

    local $username = _IEGetObjByName ($oIE, "_address")
    Local $password = _IEGetObjByID ($oIE, "login_form_password")
    Local $Signin_button = _IEGetObjByID ($oIE,"login_button")
    Local $Email_button = _IEGetObjByName ($oIE, "LOGIN")

    _IEFormElementSetValue ($username, "account@outlook.de")        ;change this to your  Account 1 Name
    _IEFormElementSetValue ($password, "xxxxx")                 ;change this to your  Account 1 Password

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc


Func gmail_Account2 ()



    local $username = _IEGetObjByName ($oIE, "_address")
    Local $password = _IEGetObjByID ($oIE, "login_form_password")
    Local $Signin_button = _IEGetObjByID ($oIE,"login_button")
    Local $Email_button = _IEGetObjByName ($oIE, "LOGIN")

    _IEFormElementSetValue ($username, "account@gmail.com")        ;change this to your  Account 2 Name
    _IEFormElementSetValue ($password, "xxxxx")                          ;change this to your  Account 2 Password

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc

Func gmail_Account3 ()

Global $oIE =_IECreate ("http://www.gmail.com")

    local $username = _IEGetObjByName ($oIE, "_address")
    Local $password = _IEGetObjByID ($oIE, "login_form_password")
    Local $Signin_button = _IEGetObjByID ($oIE,"login_button")
    Local $Email_button = _IEGetObjByName ($oIE, "LOGIN")

    _IEFormElementSetValue ($username, "account@gmail.com")        ;change this to your  Account 2 Name
    _IEFormElementSetValue ($password, "xxxxx")                      ;change this to your  Account 2 Password

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc

Func hotmail_Account1 ()

Global $oIE =_IECreate ("http://www.gmail.com")

    local $username = _IEGetObjByName ($oIE, "_address")
    Local $password = _IEGetObjByID ($oIE, "login_form_password")
    Local $Signin_button = _IEGetObjByID ($oIE,"login_button")
    Local $Email_button = _IEGetObjByName ($oIE, "LOGIN")

    _IEFormElementSetValue ($username, "account@gmail.com")        ;change this to your  Account 2 Name
    _IEFormElementSetValue ($password, "xxxxx")                 ;change this to your  Account 2 Password

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc


Func hotmail_Account2 ()

Global $oIE =_IECreate ("http://www.live.com")

    local $username = _IEGetObjByName ($oIE, "login")
    Local $password = _IEGetObjByName ($oIE, "passwd")
    Local $Signin_button = _IEGetObjByName ($oIE,"SI")

    _IEFormElementSetValue ($username, "YourAccount2@hotmail.com")         ;change this to your Hotmail Account 2 Name
    _IEFormElementSetValue ($password, "Your Password")                    ;change this to your Hotmail Account 2 Password
    _IEAction ($Signin_button, "click")

EndFunc


Func hotmail_Account3 ()

Global $oIE =_IECreate ("http://www.live.com")

    local $username = _IEGetObjByName ($oIE, "login")
    Local $password = _IEGetObjByName ($oIE, "passwd")
    Local $Signin_button = _IEGetObjByName ($oIE,"SI")

    _IEFormElementSetValue ($username, "YourAccount2@hotmail.com")         ;change this to your Hotmail Account 2 Name
    _IEFormElementSetValue ($password, "Your Password")                    ;change this to your Hotmail Account 2 Password
    _IEAction ($Signin_button, "click")

EndFunc

 

,

Edited by svenjatzu
Link to comment
Share on other sites

No need to learn Java. Have a look at the wiki and see how to work with the Webdriver UDF.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Ok the system says

Run WD_Demo.au3 and select "DemoNavigation" to validate the installation.
The result (for Firefox) displayed in the DOS window should be similar to the following:

...

1579786943938   geckodriver     DEBUG   Listening on 127.0.0.1:4444
1579786944279   webdriver::server       DEBUG   -> POST /session {"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}
1579786944280   webdriver::command      WARN    You are using deprecated legacy session negotiation patterns (desiredCapabilities/requiredCapabilities), see https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities#Legacy
1579786944313   mozrunner::runner       INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\User\\AppData\\Local\\Temp\\rust_mozprofilemiyOrM"
1579786944341   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1:51588
1579786949773   geckodriver::marionette DEBUG   Connection to Marionette established on 127.0.0.1:51588.
1579786949877   webdriver::server       DEBUG   <- 200 OK {"value":{"sessionId":"abdf9ab3-b5b0-417f-a382-c61c8652e81f","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"72.0.2","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:buildID":"20200117190643","moz:geckodriverVersion":"0.26.0","moz:headless":false,"moz:processID":9672,"moz:profile":"C:\\Users\\User\\AppData\\Local\\Temp\\rust_mozprofilemiyOrM","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}

so seems to be installed all right

but also autoitconsole shows the error_WD_CreateSession: {"value":{"sessionId":"abdf9ab3-b5b0-417f-a382-c61c8652e81f","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"72.0.2","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:buildID":"20200117190643","moz:geckodriverVersion":"0.26.0","moz:headless":false,"moz:processID":9672,"moz:profile":"C:\\Users\\User\\AppData\\Local\\Temp\\rust_mozprofilemiyOrM","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}
"C:\Users\User\Desktop\autoit free\WebDriver-0.2.0.5\wd_core.au3" (332) : ==> Unknown function name.:
Local $oJSON = Json_Decode($sResponse)

 

i dont understand? also firefox just openes and then only shows a golden navigaation bar and thats it?

 

Link to comment
Share on other sites

hmm seems like there was a permission error on md hdd...

maybe was cuz iv downloaded the files from diferent threats, now got them all from here https://www.autoitscript.com/wiki/WebDriver#Firefox_2

and now it works.

: ) thanks Danp2

 

well now i can start with my major question XD

how to make this old script work with the new udf?

#include <IE.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <Array.au3>
AutoItSetOption ( "TrayIconDebug", 1 )

#cs---------------------------------------  Auto Multi Email login  -----------------------------------------
;                                  _______
;    /\           _____  _____    |          _      _                   |      ______   _____
;   /  \   |    |   |   |     |   |____     | \    / |   /\   o |       |     |      | |       o |\  |
;  /----\  |    |   |   |     |   |      -- |  \  /  |  /--\  | |       |     |      | |  _ _  | | \ |
; /      \ |____|   |   |_____|   |_______  |   \/   | /    \ | |____   |____ |______| |_____| | |  \|
;
#ce----------------------------------------------------------------------------------------------------------



;--------------------  this is the GUI  ------------------------------------------------
$AutoEmail = GUICreate("Auto Email", 339, 125, @DesktopWidth, @DesktopHeight)
$aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "")
$aWin = WinGetPos($AutoEmail)
WinMove($AutoEmail, "", @DesktopWidth - $aWin[2] - 4, @DesktopHeight - $aWin[3] - $aTaskbar[3] - 4)

$Gmail = GUICtrlCreateButton("Freeetc", 64, 16, 49, 41, $BS_ICON)
GUICtrlSetImage(-1, "C:\Users\iresolver\Downloads\gmail_icon.ico", 1)

$Hotmail = GUICtrlCreateButton("Hotmail", 223, 16, 49, 41, $BS_ICON)
GUICtrlSetImage(-1, "C:\Users\iresolver\Downloads\MSMail_icon.ico", 1)

$cCombo = GUICtrlCreateCombo("", 16, 72, 145, 25)
GUICtrlSetData(-1, "YourAccount1@gmail.com|YourAccount2@gmail.com|YourAccount3@gmail.com", "YourAccount1@gmail.com")

$cCombo2 = GUICtrlCreateCombo("", 176, 72, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "YourAccount1@hotmail.com|YourAccount2@hotmail.com|YourAccount3@hotmail.com", "YourAccount1@hotmail.com")

GUISetState(@SW_SHOW)
;--------------------  End of GUI  ------------------------------------------------------


While 1
If $Gmail Then Gmail ()
If $Hotmail Then Hotmail ()
WEnd


Func Gmail ()
Switch GUIGetMsg ()
        Case $GUI_EVENT_CLOSE
        Exit
        Case $Gmail
            Switch GUICtrlRead($cCombo)
        Case "YourAccount1@gmail.com"          ;change this to your G-Mail Account 1
                    gmail_Account1 ()          ;Don't change this line

        Case "YourAccount2@gmail.com"          ;change this to your G-Mail Account 2
                    gmail_Account2 ()          ;Don't change this line

        Case "YourAccount3@gmail.com"          ;change this to your G-Mail Account 3
                    gmail_Account3 ()          ;Don't change this line
            EndSwitch
            EndSwitch
EndFunc

Func Hotmail ()
    Switch GUIGetMsg ()
        Case $GUI_EVENT_CLOSE
        Exit

        Case $Hotmail
        Switch GUICtrlRead($cCombo2)

        Case "YourAccount1@hotmail.com"              ;change this to your Hotmail Account 1
                    Hotmail_Account1 ()              ;Don't change this

        Case "YourAccount2@hotmail.com"              ;change this to your Hotmail Account 2
                    Hotmail_Account2 ()              ;Don't change this line

        Case "YourAccount2@hotmail.com"              ;change this to your Hotmail Account 3
                    Hotmail_Account3 ()              ;Don't change this line
     EndSwitch
     EndSwitch

EndFunc

Func gmail_Account1 ()

Global $oIE =_IECreate ("https://google")

    local $username = _IEGetObjByName ($oIE, "_address")
    Local $password = _IEGetObjByID ($oIE, "login_form_password")
    Local $Signin_button = _IEGetObjByID ($oIE,"login_button")
    Local $Email_button = _IEGetObjByName ($oIE, "LOGIN")

    _IEFormElementSetValue ($username, "xxx@outlook.de")        ;change this to your  Account 1 Name
    _IEFormElementSetValue ($password, "xxx")                 ;change this to your  Account 1 Password

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc


Func gmail_Account2 ()



    local $username = _IEGetObjByName ($oIE, "_address")
    Local $password = _IEGetObjByID ($oIE, "login_form_password")
    Local $Signin_button = _IEGetObjByID ($oIE,"login_button")
    Local $Email_button = _IEGetObjByName ($oIE, "LOGIN")

    _IEFormElementSetValue ($username, "xxx@gmail.com")        ;change this to your  Account 2 Name
    _IEFormElementSetValue ($password, "xxx")                        ;change this to your  Account 2 Password

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc

Func gmail_Account3 ()

Global $oIE =_IECreate ("https://google")

    local $username = _IEGetObjByName ($oIE, "_address")
    Local $password = _IEGetObjByID ($oIE, "login_form_password")
    Local $Signin_button = _IEGetObjByID ($oIE,"login_button")
    Local $Email_button = _IEGetObjByName ($oIE, "LOGIN")

    _IEFormElementSetValue ($username, "xxx@gmail.com")        ;change this to your  Account 2 Name
    _IEFormElementSetValue ($password, "xxx")                        ;change this to your  Account 2 Password

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc

Func hotmail_Account1 ()

Global $oIE =_IECreate ("https://google")

    local $username = _IEGetObjByName ($oIE, "_address")
    Local $password = _IEGetObjByID ($oIE, "login_form_password")
    Local $Signin_button = _IEGetObjByID ($oIE,"login_button")
    Local $Email_button = _IEGetObjByName ($oIE, "LOGIN")

    _IEFormElementSetValue ($username, "xxx@gmail.com")        ;change this to your  Account 2 Name
    _IEFormElementSetValue ($password, "xxx")                 ;change this to your  Account 2 Password

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

EndFunc


Func hotmail_Account2 ()

Global $oIE =_IECreate ("http://www.live.com")

    local $username = _IEGetObjByName ($oIE, "login")
    Local $password = _IEGetObjByName ($oIE, "passwd")
    Local $Signin_button = _IEGetObjByName ($oIE,"SI")

    _IEFormElementSetValue ($username, "YourAccount2@hotmail.com")         ;change this to your Hotmail Account 2 Name
    _IEFormElementSetValue ($password, "Your Password")                    ;change this to your Hotmail Account 2 Password
    _IEAction ($Signin_button, "click")

EndFunc


Func hotmail_Account3 ()

Global $oIE =_IECreate ("http://www.live.com")

    local $username = _IEGetObjByName ($oIE, "login")
    Local $password = _IEGetObjByName ($oIE, "passwd")
    Local $Signin_button = _IEGetObjByName ($oIE,"SI")

    _IEFormElementSetValue ($username, "YourAccount2@hotmail.com")         ;change this to your Hotmail Account 2 Name
    _IEFormElementSetValue ($password, "Your Password")                    ;change this to your Hotmail Account 2 Password
    _IEAction ($Signin_button, "click")

EndFunc

you maybe got or quickly can create an excample script that shows me how to eg login to my account on autoitscript.com ?

 

Edited by svenjatzu
Link to comment
Share on other sites

Hi again

 

im stucking on klicking a checkbox,

im trying this way

;~ $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='checkbox-spinner']")
;~ _WD_ElementAction($sSession, $sElement, 'click')

 

but i think this way wont be the right way to check the checkbox or?

this is the code so far, maybe you could please help me?

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

Local $sDesiredCapabilities, $sSession, $sElement


SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://pixabay.com/de/images/download/alaska-4714097_1920.jpg?attachment&modal")


$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@roll='presentation']")
_WD_ElementAction($sSession, $sElement, 'click')



Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
EndFunc

 

Edited by svenjatzu
Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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