Jump to content

How do I read the IE Url without knowing the IE object


Recommended Posts

Hi All,

So here is my question. In my autoit script, I click a button and it opens up an IE window and I have to validate that the right window opened up, verifying the window title and the IE url. Lets say a button is clicked from auto it script and it opens the google website. So now my auto it script needs to somehow read "Google - Microsoft Internet Explorer" (this is the title) and "http://www.google.com/" (this is the url) and validate it. I can use the IE functions in IE.au3, but my dilemma here is that since the IE browser is opened by the application by clicking a button, I donot have the IE object. How do I get a handle on this IE to get the needed information.

Any help or direction would be greatly appreciated.

Thanks

Link to comment
Share on other sites

CODE
#include "IE.au3"

#include "file.au3"

dim $IE_Browser_Title = "Google - Microsoft Internet Explorer"

dim $IE_Browser_URL = "http://www.google.com/"

dim $testCase = "TestURL"

$oIE = _IEAttach ($IE_Browser_Title)

$URL_Opened = _IEPropertyGet ($oIE, "locationurl")

MsgBox(0,"test",$URL_Opened)

If $IE_Browser_URL = $URL_Opened Then

LogTestCasePass($testCase, "Google web page with the url " &$URL_Opened& " opened up.")

_IEQuit($oIE)

Else

LogTestCaseFail($testCase, "The website with the url " &$URL_Opened& " is opened instead of the expected " &$IE_Browser_URL)

Exit

EndIf

Func LogTestCaseFail($testCase, $logMsg)

_FileWriteLog(@ScriptDir &"\"&$testCase&"_FAILED.txt", $logMsg)

EndFunc

Func LogTestCasePass($testCase, $logMsg)

_FileWriteLog(@ScriptDir &"\"&$testCase&"_passed.txt", $logMsg)

EndFunc

I am still having issues with this code. All I want to do is figure out if a webpage "google.com" is already opened or not.

Thanks

Link to comment
Share on other sites

Study the different modes for _IEAttach... what you used was a Window Title, the default is Title which is a document title (it's an HTML thing). You can also use URL and others. You've got choices... you just chose the wrong one.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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