How can I inspect a XUL popup element without it disappearing? - firefox

Firefox 31 broke my Googlebar Lite extension, and I'm trying to debug why. My problem is that mouse clicks no longer register for search suggestions that appear in the auto-complete popup menu (which comes as a part of the Firefox autocomplete textbox control). I'd like to inspect these chrome elements with DOM Inspector, but the popup closes (destroying the anonymous children) before I'm able to inspect them.
How can I inspect a popup element (in this case it's a panel) without it disappearing? Is there a way I can force that kind of element to stay open so I can examine its children?

Inspecting the autocomplete DOM would require hacking deeply into the autocomplete code to avoid making it destroy items before inspecting.
While possible, I'd first look if the autocomplete code changed, so I tried:
Finding the result interface on MXR: http://mxr.mozilla.org/mozilla-central/source/toolkit/components/autocomplete/nsIAutoCompleteResult.idl
Checking the log: http://hg.mozilla.org/mozilla-central/filelog/de8c0f0e74a2/toolkit/components/autocomplete/nsIAutoCompleteResult.idl
Checking out the newest changeset(s) and bug(s).
And indeed, Bug 754265 amended the interface.
So I implemented the interface change, implementing the new API method, and after that the broken stuff works again:
getFinalCompleteValueAt: function(index) {
return this._results[index];
},
I made a pull-request for you.

Also try installing addon "Element Inspector" it allows you Shift + Right Click anything and it pops it up in "DOM Inspector"
https://addons.mozilla.org/en-US/firefox/addon/element-inspector/

Related

Watir - clicking on element works diffrent than manualy

I wrote test in watir, and one of line doesn't work correctly:
$browser.element(:css => '#sub-15079 > div.ardbnServerInformation').click
When I click manualy on this element, browser opens new tab and everything is fine. But when watir clicks on this element, browser opens new window (instead tab) and data in window doesn't load. How to fix this difference in behaviour?
Sounds like maybe some countermeasures are being used to block the scraping efforts...some kind of javascript thing...
A surefire way to overcome these types of things is to a visual-based automation tool something like Sikuli (sikuli.org) to visually identify a link and click it. It actually uses optical recognition rather than the DOM to identify links and click them.
A more haphazard way to go about this would be to use something like cliclick to click based on screen coordinates, but this is not a very good solution in my opinion.

Selenium fails to click a checkbox under a fixed footer

I'm automating tests using Selenium on Firefox, and everything was working ok until I needed to check checkboxes that are not visible due to a footer that is fixed to the bottom of the page.
It's a long list of disclaimers that are necessary to be checked in order to continue.
The first two are below this footer, the rest forces a scroll down, and are checked correctly.
My question is:
1) Is there a way to check the first two even thought they are below the footer?
2) Is there a way to make Selenium scroll down using a command?
3) Is there a way to make Selenium to open a new Firefox window maximized? (I believe that if this is possible, all checkboxes will be visible on load)
Thank you!
PS: This is my second post, if I'm missing some information please let me know and I'll edit it.
EDIT:
Firefox version: 23.0.1
Webdriver version: 2.35
Unfortunately, i have only configured my webdriver for Firefox (not on chrome at the moment)
You don't have to scroll the page as long as you are finding the Element with correct selectors (e.g. xpath, css etc.), so something like driver.findElement(By.xpath("xpath")); should remove the need to scroll the page. As for opening the page in full screen use the following
driver.manage().window().maximize();
If your web page needs to be scrolled down to interact with element, first you'll have to bring that element into view. Using Ruby, this can be achieved by following:
element.location_once_scrolled_into_view
and then interact with element.
You can use javascript executor to scroll the page. I've found that Selenium will click objects that are "visible" but hidden behind something else on the page.
JavascriptExecutor jsx = (JavascriptExecutor)driver;
jsx.executeScript("window.scrollBy(0,450)", "");
I use the capability:
capabilities.setCapability("elementScrollBehavior", 1); // 0- from Top,
// 1 - from bottom
When I start the driver, I set the capability.

How do I run Firefox inspector within an iFrame?

I know Chrome's inspector has a selector to choose which frame to use with the console. Firebug has a similar command, cd(window.frames[number]). Is there anything similar in Firefox Devtools? I suppose frame.window.eval could work, but only if it isn't cross-domain.
I was also wondering if there is a highlighter to inspect results of Web-console commands, for example document.getElementsByClassName(...). but you can at least change style of an element programmatically to 'see' it.
DOMNode objects do highlight in the page on hover in the web console and what is called the "variables view". The "variables view" is used in the web console too when you click on an object to see its properties (it's the sidebar that appears), and is also used in the debugger when paused at a breakpoint (right sidebar that contains the various scopes variables).
So, anytime a DOMNode appears in there, if you hover over it, it will be highlighted in the page.
When it comes to iframes, the webconsole does support the cd() command, see working with iframes.
We are also actively working on a bug that will add a drop-down to the toolbox whenever there are frames/iframes in the current page and allow you to easily switch from one to the other.
You can click to inspect a node in the console and debugger starting in Firefox 29, currently on the Aurora channel.

How to programmatically invoke a Firefox button/addon

For a given button inside Firefox 4, how do I discover the appropriate way to simulate a click using XPCom/JavaScript? I'd like to programmatically invoke a dialog which is currently only reachable by clicking a toolbar button.
More info: I am happily using Mozilla's experimental F1 sharing extension from here:
http://f1.mozillamessaging.com
But I'd like to craft a custom keybinding or programmatic invocation for the share dialog (basically I want to hide my navigation bar but still invoke F1 easily).
I cannot find any straightforward way to do this? I suspect that I just need to peek at (the equivalent of) the onClick handler for the default button and then invoke that in my own XPCom code ... but this seems undiscoverable.
Any help would be much appreciated.
Peeking at the onclick handler might work, if they did it that way. But if they added the functionality using addEventListener then it would not. In that case, your best bet might be to use dispatchEvent to simulate the user clicking on that button.
https://developer.mozilla.org/en/DOM/element.dispatchEvent

Selenium RC : Button is not clicked but test passes

I have a script which enters some data in the page and click save button.
Here I used HTML component id for save button.
selenium.click("StudentID:saveData");
I even provided proper wait condition and also tried with X path locator.
The test passes. It doesn't throw any error message but the button is not clicked and the data is not getting updated.
Please let me know what might be the issue .
I had a similar problem and used a CSS selector instead. CSS selectors are much faster than Xpath (and in my experience work better in general, though Xpath is necessary for certain things).
If you are using Firefox, install the Firebug add-on; right-clicking on an element on the page will give you the option to copy CSS path. I've found that I often have to make some changes to it to get it working properly but it allows you to get to very deeply nested elements quickly.
The W3C has a good page on CSS selectors here.

Resources