Jump to content
Danp2

WebDriver UDF (W3C compliant version) - 11/21/2018

Recommended Posts

Danp2

@Lunier What version Chrome? Chromedriver? Also, what version of the UDF?

FWIW, I'm not seeing this same error. I did modify your StartRegistration function as follows to deal with the opening animation --

Func StartRegistration()
   _WD_Navigate($sSession, "https://www.dazn.com/de-DE/account/signup")
   _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='firstName']")

   $firstName = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='firstName']")
   _WD_ElementAction($sSession, $firstName , 'value', "temp")
EndFunc

 

Share this post


Link to post
Share on other sites
Lunier

Okay it seems like i used an older chromedriver version and now my codes does indeed work.

Still thank you.

Share this post


Link to post
Share on other sites
Danp2
On 1/9/2019 at 7:33 AM, danylarson said:

I wanted to highlight a table and it does not seem to works properly in my examples

Finally got around to looking at this again. Found some issues with your code. The following works for me --

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/table")
    _WD_HighlightElement($sSession, $sElement, 3)

 

Share this post


Link to post
Share on other sites
danylarson

Hi Dan,

Thanks for your review i noticed my mistake.

Here is an improved version of my fonction to get Table content :

Func _WD_GetTableContent($sSession, $aElements, $Separator, $ContainHeader = "")

    Local $BaseElement
    Local $LineNumber
    Local $ColNumber
    Local $i
    local $j
    Local $sValue
    Local $TmpValue
    Local $StartCell

    $BaseElement = $aElements

    $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $BaseElement & "/tbody/tr", "", True)
    $LineNumber = UBound($aElements)

    $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $BaseElement & "/tbody/tr[1]/td", "", True)
    $ColNumber = UBound($aElements)

    Local $sArray = [$LineNumber]

    $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $BaseElement & "/tbody/tr/td", "", True)
;~     _ArrayDisplay($aElements)

    $CellNumber = UBound($aElements)

    If $ContainHeader = "" Then

        $StartCell = 0

    Else

        $StartCell = $ColNumber

    EndIf

    For $i = $StartCell To $CellNumber - 1

        $sElement = $aElements[$i]
        $TmpValue = _WD_ElementAction($sSession, $sElement, 'Text')
        $sValue = $sValue & "##" & $TmpValue

        $j = $j + 1

        If $j = $ColNumber Then

            _ArrayAdd($sArray, $sValue)
            $sValue = ""
            $j = ""

        EndIf

    Next

    For $i = 1 To UBound($sArray) - 1

        $TmpValue = $sArray[$i]
        $TmpValue = StringMid($TmpValue, 3)
        $TmpValue = StringReplace($TmpValue, "##", $Separator)

        $sArray[$i] = $TmpValue

    Next

    Return $sArray

EndFunc   ;==>_WD_GetTableContent

Share this post


Link to post
Share on other sites
Refus

I have been having problems loading any User profile with Chrome other than the newly generated temporary one that Webdriver creates by default. 

I am using a copy of the wd_demo code just as a starting point, only having edited the DriverParams section of SetupChrome()

Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log" --user-data-dir="C:\Users\Jan\AppData\Local\Google\Chrome\User Data"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}'
EndFunc

Despite adding (what I believe to be)the correct usage of --user-data-dir, chromedriver launches with the new temp Chrome profile every time. 

 

Console:

_WDStartup: OS: WIN_10 WIN32_NT 17134 
_WDStartup: AutoIt: 3.3.14.2
_WDStartup: WD.au3: 0.1.0.17
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --user-data-dir="C:\Users\Jan\AppData\Local\Google\Chrome\User Data"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"71.0.3578.98","chrome":{"chromedriverVersion":"2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387)","userDataDir":"C:\\Users\\Jan\\AppData\\Local\\Temp\\scoped_dir3068_9340"},"goog:chromeOptions":{"debuggerAddress":"localhost:64107"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows nt","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"c2ecb7bc400269fa73565ab43480120d"}}
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"71.0.3578.98","chrome":{"chromedriverVersion":"2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387)","userDataDir":"C:\\Users\\Jan\\AppData\\Local\\Temp\\scoped_dir3068_9340"},"goog:chromeOptions":{"debuggerAddress":"localhost:64107"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows nt","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"c2ecb7bc400269fa73565ab43480120d"}}

I can see the temporary profile, but am unsure how to enforce that my -user-data-dir is followed.

What am I missing?

Thank you for your time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Davidowicza
      By Davidowicza
      Hey guys,
      I am creating my very first script that automates a browser (I usually work with program installs and database automation) and have come across an issue that I am totally stumped on. I need to click an element that gives me a drop down list box but the Xpath to the element changes with every instance of chrome I start...
      I have tried selecting the class, rect, and path but no luck. It never finds the element. (I could be doing this wrong since I am not good at HTML)
      Element I need to select:
      This is the Xpath for the last 3 instances of chrome I have run the script with:
      //*[@id="highcharts-5bp9crq-8"]/svg/g[6]/g/rect //*[@id="highcharts-fiw9szv-8"]/svg/g[6]/g/rect //*[@id="highcharts-5szkmx8-8"]/svg/g[6]/g/rect As you can see the path changes every time.
      How I am trying to select the element:
      ;Check for box element _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='highcharts-5bp9crq-8']/svg/g[6]/g") MsgBox(0, "", "check for timeout") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='highcharts-5bp9crq-8']/svg/g[6]/g") _WD_ElementAction($sSession, $sElement, 'click') Maybe someone has come across this before and found a work around without using mouseclick()
      Thanks guys, hopefully I am just very overlooking something simple and can be pointed to the right solution.
      Side Note: I wish I could share the webpage entirety, but it has sensitive information with my agency that I cannot share. If you need more, just let me know and I will try and post as much as I can.
    • Danp2
      By Danp2
      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.
    • daluu
      By daluu
      This is kind of already posted here:
      '?do=embed' frameborder='0' data-embedContent>>
      but wanted to note this in this forum of example scripts in case some people only look in this forum for examples and not the other forums with respect to AutoIt integration or relation to Selenium WebDriver.
      So, the example in summary is: you can use Selenium WebDriver API to do AutoIt GUI automation (the ControlXyz() and WinXyz() functons, along with mouse and "send keys" functions). Although I suppose that might be opposite or counter to what most examples here are about - using AutoIt to do or control other stuff rather than using other stuff to control/run AutoIt. But regardless, it is an example implementation of a different use case for AutoIt beyond the general AutoIt community, like those who also use Selenium WebDriver and/or need to integrate Selenium with AutoIt for remote deployment.
      https://github.com/daluu/AutoItDriverServer
      with specific demo examples here:
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/CalculatorTest.java
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/calculator.py
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/SeleniumIntegrationTest.java
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/SeleniumIntegrationWithAutoItDriver.py
    • TechCoder
      By TechCoder
      Below you will find both a new Marquee UDF (many W3C/HTML5 features and more) as well as a user-friendly program that both serves as an example script, as well as it will create the code for any particular marquee for you!  Enjoy!   ~~~~~~~~~~~~~~~~~  BACKGROUND on <marquee> ~~~~~~~~~~~~~~~~~ <marquee> has been classed as "non-standard" and "non-conforming" as an HTML element   (http://www.w3.org/wiki/HTML/Elements/marquee)  There is no promise that it will continue to be supported in the future, though it is obvious that many people have a need for this feature and it has remained in the major browsers for years.....   <marquee> was originally built into Internet Explorer only, now supported in other browsers, though some original features do not work in IE either - it is clearly trying to be phased out, though a 'replacement' of sorts is coming around, using HTML5 components, so I think it will never totally go away. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   For a project I'm working on, I need a way to create a LOT of different marquees.  I thought it simpler to have a program create the code needed, and built the attached 'user interface' program using various references to the feature.   THE USER PROGRAM IS BACKWARD COMPATIBLE WITH THE EXISTING UDF FROM Melba23   I also needed some features that are not part of the UDF from Melba23 that are direct references to current (HTML5) recommendations from http://www.w3.org/TR/CSS2/, so I modified the current UDF to create the additional functions, which make the UDF more HTML5 compliant (some of the features I built in have no HTML5 component, existing functions were updated only where needed for the first release - perhaps someday the rest can be done, though no immediate plans)    *******************************************************************************************************************************    KNOWN ISSUES and/or LIMITATIONS within the user program   - Tip text NOT IMPLEMENTED (from _GUICtrlMarquee_SetDisplay $sTipTxt) - I had no use for it in my project, though it is not difficult to add if you need to   - border styles do not correspond to w3.org settings (not the program's fault...) This article (http://webdesign.about.com/od/beginningcss/a/aa091207.htm) states that IE does not support 'groove', 'ridge', 'inset' or 'outset' styles, yet does support 'dotted', 'dashed' and 'double'.   Testing has proven this is true for IE (11), however, in testing AutoIt (with the Marquee UDF), which I thought uses IE (?), it appears that just the OPPOSITE of this is true.  Another item for further testing/study.........   - 'Align' feature not working 100% on all fonts (not the program's fault! the initial version of <marquee> (designed for IE and copied to other browsers later) contained an element called 'align', which has long been obsolete in favor of css 'vertical-align', however, it is not a direct replacement  and does not work inside <marquee>.     Several alternatives were tried (including 'line-height' and even 'vspace', which may also soon be phased out) and nothing works 'perfectly' (search the web on font sizing and spacing - you will see this is extremely difficult).        This program works around these challenges in a 'best effort' way, using calculations and 'top-margin' (or vspace) spacing.        'Recommended' fonts (http://www.autoitscript.com/autoit3/docs/appendix/fonts.htm) will be set to 'center' or 'bottom' (within a pixel or 2), while other fonts may be off by several pixels (something in the font is different..).        If you need the other fonts, a bit of testing would give some offset numbers that could result in better display. (this is NOT on my list to do, though maybe someone would want to take that on???)   - You can create 'unreadable', 'unusable' and even 'UGLY' marquees (not the program's fault, either!) While a bit of effort was put into limiting things, there is no cross-checking to make sure your marquee will look 'nice'.  All parameters within the marquee feature have been tested to their max/min limits (and pushed well past the documented limits for speed and delay - you can make a  F A S T  or  S L O W  marquee well outside the published specs!) and set accordingly.   Any/all color scheme, font size, etc. can be used (no matter how horrible the outcome...) so have fun and create what you like!    *******************************************************************************************************************************   Additional recommendations from w3.org built into Marquee_W3C.au3 UDF   1. Border thickness (width) refered as "thin", "medium" and "thick" or <length> (any number - to infinity)      (http://www.w3.org/TR/CSS2/box.html#border-properties)     (http://www.w3schools.com/jsref/prop_style_borderwidth.asp) Marquee_W3C UDF allows any number as an entry, as well as the more 'friendly' named terms   2. Border Style is included in Marquee_W3C UDF (not in the current UDF, therefore, none of the settings in the user program do anything if you use the old UDF, so it is set to $GUI_DISABLE.)   3. use of PIXELS and EM for formatting text instead of POINTS      http://www.w3.org/TR/CSS2/fonts.html#font-size-props use <length> paramaters      http://www.w3.org/TR/CSS2/syndata.html#value-def-length with named length units (em, ex, cm, in, px, etc.)   POINTS are used in typsetting, while PIXELS, and EM are more correct methods of sizing fonts on modern monitors (one good article on this topic can be found at http://webdesign.about.com/cs/typemeasurements/a/aa042803a.htm )   NOTE: The user program is backward compatible with the UDF from Melba23 that uses POINTS and auto-sets the parameter with the chosen UDF.    
      Marquee_W3C.au3
      MarqueeMaker.au3
×