Jump to content

Recommended Posts

Posted
  On 2/29/2020 at 1:41 PM, VodkaDiva said:

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

Expand  

Two issues here --

  • This isn't a standard select element, so you can't use this function
  • Even if it was, you aren't calling the function with the correct parameters

You've already figured out how to "pop open" the menu. Now you just need to be able to find the correct element in this popup and then click it.

P.S. Suggest that you change your Facebook password as you've posted it in your script above

Posted

Thanks dan !
I use "_WD_ElementOptionSelect" to test and forget delete :( . and i thing about to click 2 time  .
I have open "pop open" but you can see in image 1 and 2 . not thing chagne when i click select . And i can't right click to select tab to find element :( 
I use addon to check element is : //*[@id="js_bl"]/div[1]/div[1]/ul[1]/li[51]/a[1]/span[1]/span[1]
But it notworking . Cant you check for me code again . 
i waste me 2 day :( . thanks dan again ! 

xxxxxxxxxxx

Posted

Dan you really really really genius! it working. Thanks dan
Hope all good things come to you.
Thanks you again ! 

  On 2/29/2020 at 4:23 PM, Danp2 said:

This works for me --

_WD_LinkClickByText($sSession, "Thai Baht")

Change the text to match your desired currency.

Expand  

xxxxxxxxxxx

Posted

I found this information about how to connect to existing Chrome instance:

 

https://cosmocode.io/how-to-connect-selenium-to-an-existing-browser-that-was-opened-manually/

https://intellitect.com/selenium-chrome-csharp/

 

Any concept how to do that with this AutoIt UDF ?

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

I have a problem when shutdown browser with function _WD_Shutdown no working ( Chromedriver don't close ). I use chromedriver 80. I try other PC but same error.

Code for wd_demo

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

_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://www.facebook.com")
_ChromeSetInputValueById($sSession,'email','abc')
_ChromeSetInputValueById($sSession,'pass','xyz')
_WD_Shutdown()

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

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":[' & """start-maximized""," & " ""disable-infobars""" & "" & '] }}}}'
EndFunc   ;==>SetupChrome
Func _ChromeSetInputValueById($sSession,$Id,$Value)
 $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$Id&"']")
 _WD_ElementAction($sSession,$sButton,'value', $Value)
EndFunc

Log

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\ngoct\Desktop\New folder\wd_demo.au3"    
_WDStartup: OS: WIN_10 WIN32_NT 18362 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.1.0.15
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --log-path="C:\Users\ngoct\Desktop\New folder\chrome.log"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"acceptSslCerts":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a)","userDataDir":"C:\\Users\\ngoct\\AppData\\Local\\Temp\\scoped_dir11160_16333"},"cssSelectorsEnabled":true,"databaseEnabled":false,"goog:chromeOptions":{"debuggerAddress":"localhost:52928"},"handlesAlerts":true,"hasTouchScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platform":"Windows NT","rotatable":false,"setWindowRect":true,"takesHeapSnapshot":true,"takesScreenshot":true,"unhandledPromptBehavior":"","version":"80.0.3987.122","webStorageEnabled":true},"sessionId":"f4562a56f017819c4986725f6293074c"}}
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"acceptSslCerts":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a)","userDataDir":"C:\\Users\\ngoct\\AppData\\Local\\Temp\\scoped_dir11160_16333"},"cssSelectorsEnabled":true,"databaseEnabled":false,"goog:chromeOptions":{"debuggerAddress":"localhost:52928"},"handlesAlerts":true,"hasTouchScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platform":"Windows NT","rotatable":false,"setWindowRect":true,"takesHeapSnapshot":true,"takesScreenshot":true,"unhandledPromptBehavior":"","version":"80.0.3987.122","webStorageEnabled":true},"sessionId":"f4562a56f017819c4986725f6293074c"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/f4562a56f017819c4986725f6293074c/url; $sData={"url":"https://www.facebook.com"}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/f4562a56f017819c4986725f6293074c/element; $sData={"using":"xpath","value":"//input[@id='email']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"dcbc9b26-aa3d-423c-a046-3e07eba5a3b1"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"dcbc9b26-aa3d-423c-a046-3e07eba5a3b1"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/f4562a56f017819c4986725f6293074c/element/dcbc9b26-aa3d-423c-a046-3e07eba5a3b1/value; $sData={"id":"dcbc9b26-aa3d-423c-a046-3e07eba5a3b1", "text":"abc", "value":["a","b","c"]}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_ElementAction: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/f4562a56f017819c4986725f6293074c/element; $sData={"using":"xpath","value":"//input[@id='pass']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"00e3a503-4311-4440-92ae-dd3c8ef3f3ac"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"00e3a503-4311-4440-92ae-dd3c8ef3f3ac"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/f4562a56f017819c4986725f6293074c/element/00e3a503-4311-4440-92ae-dd3c8ef3f3ac/value; $sData={"id":"00e3a503-4311-4440-92ae-dd3c8ef3f3ac", "text":"xyz", "value":["x","y","z"]}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_ElementAction: {"value":null}
>Exit code: 0    Time: 16.93


How do fix.

Thanks anyone

 

Posted (edited)

Dear Dan ! 

I use this code about 1 week . but last night i have use antivirut to fix file in "services"  .and now it notwoking . i don't know how to check :( . can you hlep me ? 
When to sesion 1 it ok => go to session 2 ok => but when comebank session1 it notworking
Thanks dan

#include "wd_core.au3"
#include "wd_helper.au3"
#include <GUIConstantsEx.au3>
#include <CoProc.au3>
Global $sDesiredCapabilities, $iIndex, $sSession,$i=1
Global $nMsg, $lProcess = False
Global $sElementSelector = "//input[@name='q']"
Global $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'
Global $sFilePath = @ScriptDir & "\1.txt"

   Setupopen()
   $sSession1 = _WD_CreateSession($sDesiredCapabilities)
  _WD_Navigate($sSession1, "https://dantri.vn")     ; Link trang Info
   Setupopen()
   $sSession2 = _WD_CreateSession($sDesiredCapabilities)
  _WD_Navigate($sSession2, "https://dantri.vn")     ; Link trang Info

   _WD_Navigate($sSession1, "https://zing.vn")          ; Link trang Info
   _WD_Navigate($sSession2, "https://google.vn")        ; Link trang Info

   _WD_Navigate($sSession1, "https://kenh14.vn")        ; Link trang Info
   _WD_Navigate($sSession2, "https://kenh14.vn")        ; Link trang Info

Exit

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

 

Edited by VodkaDiva

xxxxxxxxxxx

Posted

Apologises if this has been covered before.

I would like to write a script which attaches to a Firefox session that was created by another script. i.e. both scripts are attached to the same instance of Firefox.

Is that possible?

Thanks

Kalavo 

Posted

@VodkaDiva There are a few issues with your script --

  • "Full" isn't a valid option for $_WD_DEBUG. Suggest that you leave it at the default of $_WD_DEBUG_Info until you get your script fully debugged
  • _WD_Startup should only be called once. Each time it is called it will close any previously existing webdriver consoles, which explains why you can't get back to session 1

Please provide a detailed explanation for why you are attempting to create multiple sessions and why you can't accomplish the same thing with a single session.

Posted
  On 3/12/2020 at 12:31 PM, Danp2 said:

@VodkaDiva Có một vài vấn đề với tập lệnh của bạn -

  • "Đầy đủ" không phải là một tùy chọn hợp lệ cho $ _WD_DEBUG. Đề nghị bạn để nó ở mặc định là $ _WD_DEBUG_Info cho đến khi bạn gỡ lỗi hoàn toàn cho tập lệnh của mình
  • _WD_Startup chỉ nên được gọi một lần. Mỗi lần nó được gọi, nó sẽ đóng mọi bảng điều khiển webroll trước đó, điều này giải thích tại sao bạn không thể quay lại phiên 1

Vui lòng cung cấp giải thích chi tiết về lý do tại sao bạn cố gắng tạo nhiều phiên và lý do tại sao bạn không thể hoàn thành điều tương tự với một phiên duy nhất.

Expand  

I have to open 2 chrome to login 2 facebook. And it work when i creaate 2 session to use 2 chrome . but now it not . do you thing i have install anything again ?

xxxxxxxxxxx

Posted

@VodkaDiva Not sure how this code would have previously worked unless something else has changed on your end. You previously stated

  Quote

last night i have use antivirut to fix file in "services"

Expand  

I'm unsure what was done here, so can't say if this is the reason for the failure or not.

Has anything else changed, like updating to a newer version of the Webdriver UDF or upgrading Chrome / Chromedriver?

Posted

@VodkaDiva I tried the following and it allowed me to create two separate instances of Chrome, each with it's own profile, using a single instance of Chromedriver --

#include "wd_core.au3"
Global $sDesiredCapabilities

   Setupopen()
   $sSession1 = _WD_CreateSession($sDesiredCapabilities)
  _WD_Navigate($sSession1, "https://google.com")
   $sSession2 = _WD_CreateSession($sDesiredCapabilities)
  _WD_Navigate($sSession2, "https://google.com")

  _WD_Navigate($sSession1, "https://facebook.com")
  _WD_Navigate($sSession2, "https://facebook.com")

Exit

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 = $_WD_DEBUG_Info
   ; Execute browser setup routine for user's browser selection
   Call(SetupChrome)
   _WD_Startup()
   If @error <> $_WD_ERROR_Success Then
       Exit -1
   EndIf
EndFunc

Essentially, you need to drop the 2nd call to the Setupopen routine.

Posted
  On 3/13/2020 at 12:52 AM, Danp2 said:

@VodkaDiva I tried the following and it allowed me to create two separate instances of Chrome, each with it's own profile, using a single instance of Chromedriver --

Essentially, you need to drop the 2nd call to the Setupopen routine.

Expand  

It working ! hahaha h
Love you dan ! You are the best ! 
Have a nice day dan ! Love you 

xxxxxxxxxxx

Posted

Hi @Danp2,

I'm trying to use your UDF without success, 

Following my environment configuration:

Default location of Chrome: C:\Program Files (x86)\Google\Chrome\Application
Chrome version:  80.0.3987.149 (Official Build) (64-bit)
ChromeDriver: 81.0.4044.69 on port 9515
chrome.log is empty

Windows Firewall is disabled

and when I run wd_demo.au3 I got:

_WDStartup: AutoIt:    3.3.14.5
_WDStartup: WD.au3:    0.2.0.6
_WDStartup: WinHTTP:    1.6.4.1
_WDStartup: Driver:    chromedriver.exe
_WDStartup: Params:    --log-path="C:\Temp\Programacion\A3\WEB Browser\00-WebDriver UDF\chrome.log"
_WDStartup: Port:    9515
_WD_Startup ==> General Error: Error launching web driver!

ÇThanks in advance for your help.

Posted (edited)

@jcpetu There's a newer version of the WinHTTP UDF available on Github. Please grab the updates from here.

Where did you place the chromedriver executable? If it's outside of the current directory, then you'll need to adjust the line to include the full path like this --

_WD_Option('Driver', 'c:\full\path\to\the\executable\chromedriver.exe')

Edit: You are also running the wrong version of Chromedriver. For Chrome 80, you should be running Chromedriver 80.0.3987.106

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

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