Jump to content

String Compare to Links.href problems


 Share

Recommended Posts

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $filelist = FileOpen("list.txt", 0)
Local $customerpartnumber =Null
Local $oSearchForm =Null
Local $oSearchBox =Null
Local $oLink =0
Local $oLinks =0
Local $oIE =Null
Local $aArray =Null

$filelist = FileOpen("list.txt", 0)
$LIONURL = "http://technicalstuff.technicalcompany.com/Technicalstuff/LION/main_search.jsp?nav=LION"
$oIE = _IECreate($LIONURL, 1,1,1,1)

    ;$customerpartnumber pulled from a list named list.txt
    $customerpartnumber = FileReadLine($filelist)
    ;Grab the Search Form
    $oSearchForm = _IEFormGetObjByName($oIE,"mainsearch")
    ;Grab the specific search box
    $oSearchBox = _IEFormElementGetObjByName($oSearchForm,"custPartNo")
    ;Set the value in the search box.
    _IEFormElementSetValue($oSearchBox,$customerpartnumber)
    ;MSGBox to verify what has been put in the search box.
    MsgBox($MB_SYSTEMMODAL, "Form Element Value", _IEFormElementGetValue($oSearchBox))
    ;Javascript launch to activate search function inside of webpage
    _IENavigate($oIE, "javascript: search('200')",1)
    ;Grab all of the links for the webpage and set it to the $oLinks variable.
    $oLinks = _IELinkGetCollection($oIE)
    ;For loop to iterate through the links
    For $oLink In $oLinks
        ;PROBLEM AREA Regular Expression that tries to match against the $oLink.href. There can be any number of 6 digits in this specific part of the url with regex. It should return the value to $aMatch and $aMatch should contain the value to compare it against oLink.href further down.
        $aMatch = StringRegExp($oLink.href, ('http\://technicalstuff.technicalcompany.com/technicalstuff/LION/editProject\.jsp\?prjid\=([0-9]{6})'), 2)
        ;MSG Box to print out Link href
        MsgBox(0, "Link href", $oLink.href)
        ;PROBLEM AREA If then statement that compares two strings. One of them being the Regular Expression that is suppose to return the appropriate                  ;value, and one that is the original oLink.href verify they match and click on the link.
        If $oLink.href == $aMatch Then
            _IEAction($oLink, "click")
            ExitLoop
        EndIf
    Next
    ExitLoop

The above code has comments on what is happening, and what I think the problem area should do. My main issue is when I print the value of $aMatch it returns the value of 1 instead of the character text. It always return the value of 1 even if it does not match the link I am trying to compare it against. Theoretically it should return the value when it gets match, and compare it to oLink.href and if those two variables match it should click the link. This is not happening. Any suggestions? 

 

Link to comment
Share on other sites

Hi Mikell,
Thank you for the reply. This was a part of the solution! I had to also couple that knowledge with the isArray() function to allow me to do if then statements on the variable to determine if it had a value inside of it. I did end up resolving the issue with a little tweaking! I was at it for about 14 hours before I posted!

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...