Jump to content

Recommended Posts

Posted

Glad you were able to get it going. FWIW, you generally want to avoid using the Send function when interacting with a browser. You should be able to use the one of the existing _WD functions to trigger the page's submission. It's difficult to know which method will work without more details (website/HTML involved).

P.S. I haven't tested this, but you may want to try appending the Enter keystroke to your password, ie --

_WD_ElementAction($sSession, $sElementp, 'value', $Password & @CR)

PPS. Please read this to learn the proper way to post code on the forum

Posted (edited)

Danp2, thanks for the advice, I tried the @CR macro with the password line and also tried to sleep for a second and send it by itself but neither worked. I'm guessing that there is a way to click the "login" button. Can the element button be clicked by using either element id or name? I just don't know which function would do that .

My issue was that the username and password go in super fast and then when I go to send the "ENTER" command I have to sleep for at least a second or it doesn't take.

P.S. you are right... I knew about that code button but completely forgot about it, I will make sure to use it in the future.

Cheers!

Edited by P00PDOG
Posted

danp2, well disregard my post again, i used the wrong macro, @CRFL worked like a charm, thank you.

I am left trying to figure one last thing out. Do you know how to disable the password manager in chrome using the capabilities line? I would rather not have to specify a mandatory profile if I can help it. I researched the arguments of the chrome driver but there is nothing in there that I could find.

Posted

Yup found it. Works great. I had to remove the ending brace and add it to the end of the line to make it work. Weird thing is when I added the "prefs" the "args stopped working. not a big deal really I got everything else working great. See below for anyone else looking for the answer...

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, "prefs": {"credentials_enable_service": false, "args": ["--window-size=1600,960"] }}}}}'

Anyway thanks for all the help, really appreciated.

Posted

The above mistakenly had the arguments in the wrong position, the above works except for the "args" statement.

This did the trick,  now "args" work too.

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, "args": ["--window-size=1280,960"], "prefs": {"credentials_enable_service": false }}}}}'

 

 

Posted

Hi, 

I have followed this video

to make a test script that will search. 

https://finance.yahoo.com/


 

#include "wd_core.au3"
#include "wd_helper.au3"
Local $sDesiredCapabilities, $sSession
SetupChrome()

_WD_Startup()


$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "http://finance.yahoo.com")
_ChromeSetInputValueById( $sSession, 'yfin-usr-qry', 'Pandora')
_WD_Shutdown()

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

    ;$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":[' & """
    ;$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}}}'
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["user-data-dir=userData"] } }}}'
EndFunc

Func _ChromeSetInputValueById( $sSession, $Id, $Value)
    $sButton = _WD_FindElement( $sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$Id&"']'" )
    _WD_ElementAction( $sSession, $sButton, 'value', $Value)
EndFunc

 

I get this error message

_WD_CreateSession ==> Webdriver Exception: invalid argument: unrecognized capability: chromeOptions

Do we have one place to read up on how to contruct the $sDesiredCapabilities string ? 

thanks :)

Posted (edited)

When you open the WebDriver wiki you will find the "Reference" section at the end.
Double post.

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

When you open the WebDriver wiki you will find the "Reference" section at the end.
Select the Chrome link and you will find what you need ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

Hi dan.. im try both this and same error WD_FindElement or WD_ElementAction ? thanks in advance dan..

//first code

$ChooseBtn = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='ContentPlaceHolder1_myFile']")
_WD_ElementAction($sSession, $ChooseBtn, 'click')

//second code

$ChooseBtn = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='ContentPlaceHolder1_myFile']")
    _WD_ElementAction($sSession, $ChooseBtn, 'click')

ERROR CODE

__WD_Post: URL=HTTP://127.0.0.1:9515/session/2458b619fe4077fdb5fa7517c3b41ce6/element; $sData={"using":"xpath","value":"//*[@id='ContentPlaceHolder1_myFile']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"5751e49c-6972-4f50-ae6b-efaca5823cf9"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"5751e49c-6972-4f50-ae6b-efaca5823cf9"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/2458b619fe4077fdb5fa7517c3b41ce6/element/5751e49c-6972-4f50-ae6b-efaca5823cf9/click; $sData={"id":"5751e49c-6972-4f50-ae6b-efaca5823cf9"}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument\n  (Session info: chrome=80.0.3987.106)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011A0C83+1707139]\n\tOrdinal0 [0x011068F1+1075441]\n\tOrdinal0 [0x0107DE72+515698]\n\tOrdinal0 [0x01013F8F+81807]\n\tOrdinal0 [0x01029E9D+171677]\n\tOrdinal0 [0x01013916+80150]\n\tOrdinal0 [0x0102A0E1+172257]\n\tOrdinal0 [0x010330F4+209140]\n\tOrdinal0 [0x01029D4B+171339]\n\tOrdinal0 [0x01011D4A+73034]\n\tOrdinal0 [0x01012DC0+77248]\n\tOrdinal0 [0x01012D59+77145]\n\tOrdinal0 [0x0111BB67+1162087]\n\tGetHandleVerifier [0x0123A966+508998]\n\tGetHandleVerifier [0x0123A6A4+508292]\n\tGetHandleVerifier [0x0124F7B7+594583]\n\tGetHandleVerifier [0x0123B1D6+511158]\n\tOrdinal0 [0x0111402C+1130540]\n\tOrdinal0 [0x0111D4CB+1168587]\n\tOrdinal0 [0x0111D633+1168947]\n\tOrdinal0 [0x01135B35+1268533]\n\tBaseThreadInitThunk [0x74E70419+25]\n\tRtlGetAppContainerNamedObjectPath [0x7710662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x771065FD+189]\n"}}
_WD_ElementAction: {"value":{"error":"invalid argument","message":"invalid argument\n  (Session info: chrome=80.0.3987....
_WD_ElementAction ==> Webdriver Exception: {"value":{"error":"invalid argument","message":"invalid argument\n  (Session info: chrome=80.0.3987.106)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011A0C83+1707139]\n\tOrdinal0 [0x011068F1+1075441]\n\tOrdinal0 [0x0107DE72+515698]\n\tOrdinal0 [0x01013F8F+81807]\n\tOrdinal0 [0x01029E9D+171677]\n\tOrdinal0 [0x01013916+80150]\n\tOrdinal0 [0x0102A0E1+172257]\n\tOrdinal0 [0x010330F4+209140]\n\tOrdinal0 [0x01029D4B+171339]\n\tOrdinal0 [0x01011D4A+73034]\n\tOrdinal0 [0x01012DC0+77248]\n\tOrdinal0 [0x01012D59+77145]\n\tOrdinal0 [0x0111BB67+1162087]\n\tGetHandleVerifier [0x0123A966+508998]\n\tGetHandleVerifier [0x0123A6A4+508292]\n\tGetHandleVerifier [0x0124F7B7+594583]\n\tGetHandleVerifier [0x0123B1D6+511158]\n\tOrdinal0 [0x0111402C+1130540]\n\tOrdinal0 [0x0111D4CB+1168587]\n\tOrdinal0 [0x0111D633+1168947]\n\tOrdinal0 [0x01135B35+1268533]\n\tBaseThreadInitThunk [0x74E70419+25]\n\tRtlGetAppContainerNamedObjectPath [0x7710662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x771065FD+189]\n"}}

 

Capture.PNG

Edited by moxasya
Posted

hello, You can help me, I use chrome selenium to login but it doesn't show the profile I created :((

 

#include "wd_core.au3"
#include "wd_helper.au3"
#include "EncodeHtmlEntities.au3"
#RequireAdmin
Local    $sDesiredCapabilities,$sSession,$Sv_Data,$File_Error,$time_delay
        $user_profile='C:\\Users\\24h\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 1'


        _WD_Option('Driver', 'chromedriver.exe')
        _WD_Option('Port', 9515)
        _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
        $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true,"args":["user-data-dir='&$user_profile&'"] }}}}'

        _WD_Startup()
        Sleep(7000)
        $sSession=_WD_CreateSession($sDesiredCapabilities)
        _WD_Navigate($sSession,'https://www.google.com')
        _WD_LoadWait($sSession)

Posted (edited)

Hi everybody . i need help about select facebook tab. 

image 1 : e need click "Currency" to change money type to " US dollar"  and i can click it . but when to chose "US dollar " i search f12 don't have any thing about this tab . and i use check element and use this code. 
 

#include "wd_core.au3"
#include "wd_helper.au3"
#include <GUIConstantsEx.au3>
Local $sDesiredCapabilities, $iIndex, $sSession
Local $nMsg, $lProcess = False
Main()
Func Main()
Setupopen()
$sSession = _WD_CreateSession($sDesiredCapabilities)

   ;_WD_Navigate($sSession, "http://facebook.com")
   ;_WD_Action($sSession,"refresh")
   _WD_Navigate($sSession, "https://business.facebook.com/ads/manager/account_settings/information")       

   $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='email']")                   
   _WD_ElementAction($sSession, $sElement, 'value', "100046163019287")
    Sleep(500)
   $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='pass']")                   
   _WD_ElementAction($sSession, $sElement, 'value', "291203")
    Sleep(500)
    $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='loginbutton']")              
    _WD_ElementAction($sSession, $sButton, 'click')
   Sleep(10500)
   $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@rel='dialog']")                       
    _WD_ElementAction($sSession, $sButton, 'click')
    Sleep(10500)
   ;Code need fix here .thanks you ________________________________________________________________
   $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[@class='_4o_3 _3-99']")                      
    _WD_ElementAction($sSession, $sButton, 'click')
   Sleep(2000)

_WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "//span[@class='_4o_3 _3-99']","US Dollars (USD)")   ; Test click "us doolar"  1
   Sleep(2000)

$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@class='js_9o']/div[1]/div[1]/ul[1]/li[51]")          ; Test click "us doolar"  2
    _WD_ElementAction($sSession, $sButton, 'click')
   Sleep(2000)

 ;Code need fix here .thanks you ________________________________________________________________
   $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[id='u_4k_8']")                       
    _WD_ElementAction($sSession, $sButton, 'click')
EndFunc

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

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}'
EndFunc
Func Setupopen()
   ; Set debug level
   $_WD_DEBUG = "Full"
   ; Execute browser setup routine for user's browser selection
   Call(SetupChrome)
   _WD_Startup()
   If @error <> $_WD_ERROR_Success Then
       Exit -1
   EndIf
EndFunc




Some one can help me? thanks you .

1.PNG

2.PNG

Edited by VodkaDiva

xxxxxxxxxxx

Posted

First read:

and this:

https://www.autoitscript.com/wiki/Forum_FAQ#How_can_I_post_.22code.22_on_the_forum_.3F

also:
https://www.autoitscript.com/wiki/Forum_FAQ#How_can_I_edit_my_post_on_the_forum_.3F

so I propose you to edit your post because the code you posted is not posted well (is not formated).

 

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

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

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