Jump to content

WebDriver UDF - Help & Support


Recommended Posts

  • Replies 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

This is the "General Help and Support" thread for the WebDriver UDF. The UDF itself can be downloaded here. So if you have any questions, suggestions or errors please post here.

use the _WD_ElementAction function like this: $sValue = _WD_ElementAction($sSession, $sElement, 'attribute', 'src') p.s. ... and remove @src from the xPath: "//img[@alt='NiceGirl']"

Time ago I wrote a function to extract data from  the source HTML code of tables. https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/ Seems that that fun

Posted Images

Hi everyone , I have 1 web code

<img id="wlspispHIPBimg0b608e68c33294658a1503edc3d55e2eb0" aria-label="NiceGirl" alt="NiceGirl" src="https://kenh14cdn.com/2019/2/24/3561716420480213454575853861059020806684672n-15510057259571546306615.jpg" style="display: inline; width: 100%; height: auto; max-width: 200px;" class="text-body">

Now I want get the text "https://kenh14cdn.com/2019/2/24/3561716420480213454575853861059020806684672n-15510057259571546306615.jpg" 

I use this code 

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//img[@alt='NiceGirl']@src") 
$sValue = _WD_ElementAction($sSession, $sElement, 'attribute') 
MsgBox(0,0,$sValue)

But not success, can you tell me, what's wrong in my code. Thank !

 

 

 

 

Link to post
Share on other sites

use the _WD_ElementAction function like this:

$sValue = _WD_ElementAction($sSession, $sElement, 'attribute', 'src')

p.s.

... and remove @src from the xPath: "//img[@alt='NiceGirl']"

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to post
Share on other sites

Hello Danp2, you mentioned _WD_ElementOptionSelect, but I am trying to select an item in an "ul" unordered list. Can you use this for that ... also you make a mention of you added _WD_ElementOptionSelect in wd_core.au3, but I don't see it in the file... no header description or anything...

 

Link to post
Share on other sites
2 hours ago, Danp2 said:

@trangtrau We can't provide assistance without additional details. For starters, what is the website's URL?

ex: https://signup.live.com/signup?lcid=1 the language  follow base of pc seting or chrome setting. But i want it allway display english. I search google but don't know how to config webdriver:

 

My chrome_startup :

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, "binary":"' & StringReplace (@ScriptDir, "\", "/") & '/Chrome/App/Chrome-bin/chrome.exe"}}}}'
EndFunc

 

how to convert  the value lang form

options = webdriver.ChromeOptions()
options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
driver = webdriver.Chrome(chrome_options=options)

 

 

Link to post
Share on other sites
14 minutes ago, Danp2 said:

@trangtrau Could be wrong, but I believe add_experimental_option is specific to selenium. There's an example of setting the prefs option here. Suggest that you review that and then adapt your desiredCapabilities string to suit your needs.

thank you, It success with code  
 

Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"' )
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions":{"prefs": {"intl.accept_languages": "vi,vi_VI"},"w3c":true, "binary":"' & StringReplace (@ScriptDir, "\", "/") & '/Chrome/App/Chrome-bin/chrome.exe"}}}}'
EndFunc

 

Link to post
Share on other sites

Dear friends of modern technology😀

I run into a small problem with the webdriver udf: The URL bar remains selected after, when I navigate to a website for the first time (after Create Session)

Like this:  

url.PNG.1b7918280ea04a8c5505d2d8ff46066c.PNG

$sSession = _WD_CreateSession($sDesiredCapabilities)
   _WD_Navigate($sSession, "https://www.google.com/")

Has anyone got a good idea how to solve this? My idea was to refresh the page using _WD_Action or just perform a regular mouseclick on a random location. But I feel that there is a more attractive way to solve this? Thanks for help!

Link to post
Share on other sites

@_leo_ That isn't what I'm seeing with both Chrome and Firefox. Perhaps you can provide a more detailed description of your environment, ie --

  • Windows version
  • Webdriver UDF version
  • Browser name and version
  • etc

You could also post a simple, but complete script that we can run to observe the issue. Finally, you might want to explain why this is causing a problem for you. 😉

Link to post
Share on other sites

@Danp2 I am using windows 10, Google Chrome with Version 75.0.3770.142. and the latest UDF version.

I figured out that this is caused by "user-data-dir=userData", since it doesnt happen if I delete this part. Does anyone have an idea on how to have all the user data without the url bar getting highlighted?

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

   Global $sSession, $sSession2
   Global $sDesiredCapabilities

   SetupChrome()
   _WD_Startup()

   $sSession = _WD_CreateSession($sDesiredCapabilities)
   _WD_Navigate($sSession, "http://www.google.com")


   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, "args":["start-maximized", "disable-infobars", "user-data-dir=userData"] }}}}'
   EndFunc

And the reasons are: 1. I seem to get more "element not interactable" errors when the focus remains on the url. 2. It hurts my eyes 😅

 

Link to post
Share on other sites
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By levila
      Hi Guys, i just do some codding to automate login to some of the web.
      I manage to do the script but somehow after script done, some weird box popup. and keep looping until i close the main chrome.exe

      here is my code. kinldy pls assist, im very new to webdriver udf.
      #NoTrayIcon #include "wd_core.au3" #include "wd_helper.au3" $_WD_DEBUG = $_WD_DEBUG_None ; You could also use $_WD_DEBUG_Error Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://someoftheweb.com") _ChromeSetInputValueByName($sSession, "inputName", "Username") _ChromeSetInputValueById($sSession, "inputPassword", "Password") _ChromeSetMouseClick($sSession, "submit", "click") _WD_Shutdown() 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, "args":["--no-sandbox"]}}}}' EndFunc Func _ChromeSetInputValueByName($sSession,$name,$Value) $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$name&"']") _WD_ElementAction($sSession,$sButton,'value', $Value) EndFunc Func _ChromeSetInputValueById($sSession,$Id,$Value) $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$Id&"']") _WD_ElementAction($sSession,$sButton,'value', $Value) EndFunc Func _ChromeSetMouseClick($sSession,$Id,$Value) $sButton = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//button[@type='"&$Id&"']") _WD_ElementAction($sSession, $sButton, 'click', $Value) EndFunc  
    • By RohanM
      Hi Team,
      is there is a way to embed the webpage in auto it GUI using webdriver? what I want to do is that, I want to open edge browser inside the AutoIT GUI, in IE we have _IECreateEmbedded function but for the webdriver I am not able to find a function, please help  
      Rohan M
    • By Danp2
      Introduction
      This UDF will allow you to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings.
      Requirements
      JSON UDF https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn
      WinHTTP UDF https://www.autoitscript.com/forum/topic/84133-winhttp-functions/
      HtmlTable2Array UDF (optional) https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/
      WebDriver for desired browser
      Chrome WebDriver https://sites.google.com/a/chromium.org/chromedriver/downloads FireFox WebDriver https://github.com/mozilla/geckodriver/releases Edge WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Source Code
      You will always be able to find the latest version in the GitHub Repo 
      Help / Support
      See the wiki for details on the UDF --
      https://www.autoitscript.com/wiki/WebDriver
      Please post any questions, suggestions or errors in the GH&S thread.
      https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/
      Previous support threads (Closed)
      https://www.autoitscript.com/forum/topic/192730-webdriver-udf-help-support/
      https://www.autoitscript.com/forum/topic/201106-webdriver-udf-help-support-ii/
       
    • By goku200
      I am trying to change the settings of the print option to Save as PDF and its not changing the settings and clicking on the Save button at the bottom. Here is my script that I have written and the format is correct below. Chrome browser I'm using is 97.0 My script was working fine using Chrome 95.0\ Not sure why its not working now
      It finds the print-preview-app element but not the others.
       
    • By goku200
      I am trying to hit the Return key without having to use the Send keys. I have the following code and its not hitting the Return key. Am I missing something?
      ; Press Return $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE006"},' ; Pause $sAction &= '{"type": "pause", "duration": 500},' ; Release Return $sAction &= '{"type": "keyUp", "value": "\uE006"}]}]}' _WD_Action($sSession, "actions", $sAction)  
×
×
  • Create New...