Jump to content

Auto IT Resources to Take Learning to a new level


Recommended Posts

I do a lot of automation testing with Autoit both Web UDF driver and Windows applications 

 

I was just thinking my skills have remained about the same for the last year or so. 

What can I do to take my skills to a new level? 

What resources can I learn Auto IT to a better depth? 

As an example of my current skill level here is a function I wrote to

  1. Test an Xpath equals X
  2. If it fails to get the element it will default to mouse clicks 
  3. Which will hover over where the text on the page is 
  4. Then double click (to highlight) and compare the $TestToBeTested against what is in the clipboard using the ClipGet() function 
Func WebDriver_Test_Xpath($sSession, $Xpath, $TextToBeTested, $TestDescription, $X, $Y )
WriteToConsoleAndLog("-----------------------------------Entering WebDriver_Test_Xpath() function ------------------------------------------")
      $ClipData = ""
      Sleep(1000)
      $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $Xpath)
      if @error then
         WriteToConsoleAndLog("ERROR Cannot see element for Xpath: " & $Xpath)
         WriteToConsoleAndLog("ERROR Test Description:  " & $TestDescription)
         WriteToConsoleAndLog("ERROR $Element equals:  " & $sElement)
         if $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $Xpath) Then
            WriteToConsoleAndLog("---LOG: Success at getting element 2nd time")
            $ClipData = _WD_ElementAction($sSession, $sElement, 'property', 'value')
            $inner = _WD_ElementAction($sSession, $sElement, 'property', 'innerText')
            $textContent = _WD_ElementAction($sSession, $sElement, 'property', 'text')

            WriteToConsoleAndLog("---Log: value equals: ")
            WriteToConsoleAndLog($ClipData)
            WriteToConsoleAndLog("---Log: inner Text equals: ")
            WriteToConsoleAndLog($inner)
            WriteToConsoleAndLog("---Log: $textContent equals: ")
            WriteToConsoleAndLog($textContent)

         Else
            WriteToConsoleAndLog("---ERROR: Failure at getting element 2nd time $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $Xpath)")
         endif
                 if $AttemptIfStatement_MouseClicks == true then
                  ClickALocation_ThenCopyTheSelection($X, $Y, 3)
                  $ClipData = ClipGet()
                  WriteToConsoleAndLog("----Log:  $ClipData equals: " & $ClipData )
                  endif
      Else
         $ClipData = _WD_ElementAction($sSession, $sElement, 'property', 'innerText')
            if $ClipData = "" Then
               WriteToConsoleAndLog('---Log: $ClipData is NULL on  _WD_ElementAction($sSession, $sElement, property, innerText)')
               WriteToConsoleAndLog('---Log: Will now retrieve $ClipData as VALUE instead of innerText: $ClipData =  _WD_ElementAction($sSession, $sElement, property, value)')
               $ClipData = _WD_ElementAction($sSession, $sElement, 'property', 'value')
               EndIf
         WriteToConsoleAndLog("---Log: Success on $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $Xpath) - 1st Else Statement")
         WriteToConsoleAndLog("---Log:$ClipData equals: " & $ClipData)
     EndIf
     if _WD_HighlightElements($sSession, $sElement) then
        WriteToConsoleAndLog("-----Log:  Highlighted Element Correctly")
     Else
         WriteToConsoleAndLog("-----Log:  Did not Highlighted Element Correctly")
      EndIf

      TestVariableContainsInClipBoardOne($ClipData, $TextToBeTested, $TestDescription)
 WriteToConsoleAndLog("-----------------------------------End WebDriver_Test_Xpath() function ------------------------------------------")
Endfunc

 

Link to comment
Share on other sites

At least for me the most precious resource is the help file. Everything it's described pretty well and comes with one or more examples that shows you how it works. After you master the basics you can learn things very quickly by visiting the AutoIt Example Scripts forum. Look there at different scripts even if they are not what you're interested at this moment but because you can learn different approaches of writing code.

When the words fail... music speaks.

Link to comment
Share on other sites

I'm not an expert on that particular scenario, but your AutoIt code seems clean enough, except for one If-Then that's badly indented. It apparently does the job it is intended to. I would have combined some of those back-to-back WriteToConsoleAndLog calls into one using the ampersand and the '@CRLF' but that's just me.

Maybe your "lack of progress" on skills simply reflects that your skills meet your job. You can certainly learn things that are not needed for your current job, if you feel that's helpful in the long run. But adding unnecessary complexity to the current situation is likely not helpful.

Edited by quickbeam
Added if-then phrase to first sentence.
Link to comment
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
 Share

  • Recently Browsing   0 members

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