klaymon Posted September 13, 2019 Posted September 13, 2019 I have a script that loads an IE instance and opens a web site. It will then enter a set of test credentials. If the site is running normally, it will return with the URL having extra text appended to the root URL. For example, I go to the site "http://orders.website.com/web/" and enter my credentials. When I enter the test credentials and the login fails (as it should) the URL in IE changes to "http://orders.website.com/web/index.jsp?err=Invalid%20User%20ID%20or%20password". I need to be able to read the entire URL (I have more code looking for the word "Invalid"). The problem is the "locationurl" function is only returning the "http://orders.website.com/web/" portion of the URL. Basic code follows (I'm new to the program so maybe I'm doing it wrong): #include <Inet.au3> #include <ie.au3> Local $oIE = _IECreate("http://website.com/") ControlSend("","","","test") Send("{TAB}") ControlSend("","","","test") Send("{ENTER}") $Text = _IEPropertyGet($oIE,"locationurl") MsgBox($MB_OK, "URL", $Text) Any help is appreciated.
klaymon Posted September 13, 2019 Author Posted September 13, 2019 Apparently I can't edit my post, but disregard the discrepancy between the URL in my text and the URL in my code.
Subz Posted September 13, 2019 Posted September 13, 2019 You could use _IEFormElementSetValue to set the username and passsword and _IEAction to click the submit, you could also try using _IEAttach to check if the page was redirected successfully or not, something like: $oIE = _IEAttach("http://wwww.website.com/success", "url") ;~ You could use page title if it different from failure page. If @error Then ;~ login has failed $oIE = _IEAttach(""http://orders.website.com/web/index.jsp?err=Invalid%20User%20ID%20or%20password", "url") If @error Then Exit MsgBox(4096, "Error", "Unknown url") EndIf $Text = _IEPropertyGet($oIE,"locationurl") MsgBox($MB_OK, "URL", $Text)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now