Zohar Posted November 23, 2014 Share Posted November 23, 2014 (edited) Hi New thing that appeared lately in webpages: the jQuery.fancybox. Websites are using it instead of a regular MsgBox(which is a real window) - in this case the "fancybox" is not a new window that is opened, but simply another layer on top of the webpage. My question: How to detect when a webpage has shown a fancybox? I need to wait for it, and know when it appeared. Thank you Edited November 24, 2014 by Zohar Link to comment Share on other sites More sharing options...
Danp2 Posted November 23, 2014 Share Posted November 23, 2014 You didn't specify, so I assume you are using IE. The following should work as long as the website is using a recent version of fancybox: Local $result = $oIE.document.parentwindow.eval('$.fancybox.isOpen;') MsgBox(0, "Result", $result) Zohar 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Zohar Posted November 23, 2014 Author Share Posted November 23, 2014 (edited) You didn't specify, so I assume you are using IE. Oh sorry, yes I am using IE8, on Windows XP SP3. The following should work as long as the website is using a recent version of fancybox: Local $result = $oIE.document.parentwindow.eval('$.fancybox.isOpen;') MsgBox(0, "Result", $result) Wow - works amazing! Didn't expect it to be so simple and to work right ahead Thank you very much. BTW, what does the $ mean? Edited November 23, 2014 by Zohar Link to comment Share on other sites More sharing options...
Danp2 Posted November 23, 2014 Share Posted November 23, 2014 $ is an alias for the jQuery object. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Zohar Posted November 23, 2014 Author Share Posted November 23, 2014 Cool. BTW, In that fancybox, I have 2 buttons, and I need to click one of them. What is the best way to do it? I know how to click a button when using regular webpages.. I usually get an object of the element like this: $oIE.document.getElementById("SomeID") and then perform a .click() on it. But how do I do it now with the fancybox's buttons? Link to comment Share on other sites More sharing options...
Danp2 Posted November 23, 2014 Share Posted November 23, 2014 The fancybox is just a some html within a div. Find the div and then locate the desired button within it. If you need further help, post a link to a website and your sample script to show what you've tried thus far. trancexx 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Zohar Posted November 23, 2014 Author Share Posted November 23, 2014 The fancybox is just a some html within a div. Find the div and then locate the desired button within it. You're right. I found it, and it's just like with regular HTML.. I used $oIE.document.getElementById(), and it worked. Your web development knowledge is great Link to comment Share on other sites More sharing options...
Zohar Posted November 23, 2014 Author Share Posted November 23, 2014 (edited) There is one last thing that I am curious about regarding this. The webpage that I automated, has 2 frames, a top frame, and a bottom one. The fancybox appears inside the Bottom Frame. I have 3 object variables: $oIE: The main object $oFT: The Top Frame $oFB: The Bottom Frame When I do $oFB.document.parentwindow.eval("$.fancybox.isOpen;") then it works, and gives me True or False accordingly, which is OK. But when I do $oIE.document.parentwindow.eval("$.fancybox.isOpen;") I get an error: The reason I don't understand why it happens, is because in both expressions we have the .document.parentwindow. part.. Isn't the ".parentwindow" of both $oFB and $oIE the same? Isn't parentwindow the IE Window? Note: Msg() is a small function that I wrote, that gets 1 string, and then sends it to a MsgBox() function.. Edited November 23, 2014 by Zohar Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 23, 2014 Moderators Share Posted November 23, 2014 The reason I don't understand why it happens, is because in both expressions we have the .document.parentwindow. part.. Isn't the ".parentwindow" of both $oFB and $oIE the same? Isn't parentwindow the IE Window? The short answer is "no". If you had tabs open, each tab would have it's own individual object, thus it's own individual document and parentwindow. Frames are separate webpages. Consider each frame an individual webpage as if you had them in separate tabs. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zohar Posted November 23, 2014 Author Share Posted November 23, 2014 (edited) Frames are separate webpages. Consider each frame an individual webpage as if you had them in separate tabs. OK. 1 more interesting info. I tried writing $oFB.eval("$.fancybox.isOpen;") instead of the previous $oFB.document.parentwindow.eval("$.fancybox.isOpen;") Both work.. It gives the correct True/False value, and it does not cause an error.. So it seems that the .document.parentwindow part is not needed even.. What does it mean then? Edited November 23, 2014 by Zohar Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 23, 2014 Moderators Share Posted November 23, 2014 (edited) My guess is that the frame is the parent document object. Edit: IE.au3 has some functions that are not listed. One of them is: __IEIsObjType() You could check and verify through that what exactly your object type is. Edited November 23, 2014 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zohar Posted November 23, 2014 Author Share Posted November 23, 2014 (edited) Hmm After some more testings I get a weird behavior: For the page that has the frames, I can omit the .document.parentwindow part, and it still works great. But If I go to a page that doesn't have frames, and try to omit the .document.parentwindow part, I get an error. So it seems that omitting it only works well when in a webpage with frames.. For this reason I will put the .document.parentwindow part back.. so it will work well in both places. I wish I could understand the structure better.. Edited November 23, 2014 by Zohar Link to comment Share on other sites More sharing options...
Gianni Posted November 24, 2014 Share Posted November 24, 2014 (edited) Hmm After some more testings I get a weird behavior: For the page that has the frames, I can omit the .document.parentwindow part, and it still works great. But If I go to a page that doesn't have frames, and try to omit the .document.parentwindow part, I get an error. So it seems that omitting it only works well when in a webpage with frames.. For this reason I will put the .document.parentwindow part back.. so it will work well in both places. I wish I could understand the structure better.. maybe here some info about frames that could interest you: Edited November 24, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Zohar Posted November 25, 2014 Author Share Posted November 25, 2014 Hi Chimp Thank you, I have read now the 2 pages you gave links to, and I understand the concept of nesting frames. However I do not understand why .document.parentwindow is needed here. And why in some cases the short form worked, but not in all: $oFB.eval("$.fancybox.isOpen;") as opposed to the long form which works good for all cases: $oFB.document.parentwindow.eval("$.fancybox.isOpen;") the reasn I am curious regarding this, is because the .eval() function. It seems useful, and I know I would want to use it in the future for other things besides the current(fancybox) issue, so I wonder when can I simply write .eval(), and when do I need to go thru the longer form of .document.parentwindow.eval(). Link to comment Share on other sites More sharing options...
Danp2 Posted November 25, 2014 Share Posted November 25, 2014 I'm wondering if you could be running into a scope issue, where jQuery isn't always registered at the frame level. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Zohar Posted December 22, 2014 Author Share Posted December 22, 2014 I don't know but so far my code is working very well. Thank you all Link to comment Share on other sites More sharing options...
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