Cannot see xpath / html code / firepath for popup window - firefox

I am using firebug and firepath to see xpath or html code to use in my Selenium tests. But for one popup window I cannot see any html code or firepath...
I also tried to right click to see xpath but I do not get any menu when right clicking on the popup.
It works fine on the rest of the wesite it is only this popup.. Is there any setting or something I have to do?

This is a java script alert. You will have to switch to the alert and then Use alert.accept() to mimic clicking on OK button of the alert.

Related

How do I click dropdown arrow in Facebook programmatically with VB.NET?

I'm looking for a way to programmatically click the drop-down arrow that appears when we open a specific FB post such as https://www.facebook.com/userxxx/posts/10155300116786742
Can anyone please provide me the code for Visual Basic? Thank you.
Drop-down arrow
in your webbrowser control you can invoke javascript code inside of the requested page by using
WebBrowser.Document.InvokeScript("eval", "some javascrtip here")
that leaves us with the problem of doing the dropdown click with javascript. That you can do with:
document.querySelectorAll("[data-testid=post_chevron_button]")[0].click()
so, all together it end up being
Dim micode As Object() = {"document.querySelectorAll('[data-testid=post_chevron_button]')[0].click()
"}
WebBrowser.Document.InvokeScript("eval", micode)
notice the js code provided might change. You should decide what code is better yourself. I recommend open facebook or any page, in chrome and press F12 ... that is the developer console. You can run and debug javascript there.... have fun!

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 to install Firebug lite IE8?

So we have reached that stage in a web dev project where we need to see how things look in IE.
Sigh.
So the fabulous Firebug is not available for IE. But a lite version is - as a bookmarklet, and is apparently compatible with IE6+. But how the how the hell do I add a bookmarklet to IE8?
I am unable to drag and drop to the Favourites bar (is this the same as bookmarks?). I can't add it through the Favourites add option as it contains "illegal" characters.
So how do I do this? All I want to do is inspect the DOM.
Thanks
this is how I did it (IE 8.0.7600.16385 on Win7):
Go to some Firebug Lite page (http://getfirebug.com/firebuglite).
Click the "add to Favorites Bar"
button on the Favorites Bar.
This
will give you a bookmark to
http://getfirebug.com/firebuglite.
click on the "Firebug Lite" link in Firebug Lite page (http://getfirebug.com/firebuglite).
properties poup will be open. Copy the URL within the popup
Right click on your new bookmark and choose Properties.
Paste the URL into the URL box and close.
If you hover over the new bookmark, it should show javascript:(function(F,i,r,e,b,u,g,L,I,T,E)... etc instead of the link.
Please use this in your jsp
<script type="text/javascript" src="https://getfirebug.com/firebug-lite-debug.js"></script>
and you are done.

Webdriver: Click "Share Location" button in Firefox

I am trying to use Webdriver to test a location aware website and would like to programatically (using WebDriver API call) click on the "Share Location" button that pops up when I click on a link to the location aware part of the web application.
It is a browser prompt and does not seem to be a DOM element or javascript popup element.
In case anyone is interested in knowing...
I don't believe you can use the webdriver to click that button since it's not in the DOM (ie. not part of the web document) as suggested by other answers. However, you can create firefox profiles to manipulate geolocations or change the "Share Location" setting to "Allow" in Firefox.
See the following link for more info:
http://selenium.polteq.com/nl/change-geolocation-in-firefox-with-selenium-webdriver/
You should start Firefox manually once - and select the profile you use for Selenium.
Type about:permissions in the address line; find the name of your host - and select share location : "allow".
That's all. Now your Selenium test cases will not see that dreaded browser dialog which is not in the DOM.
You can try locating by xpath //input[#value="Share Location"] is it is an <input type=button>, or probably you can try //button[contains(., "Share Location")] if it is a <button> element

How to view "generated HTML code" in Firefox?

If using Firebug, we can click on the HTML tab, and click to expand each element to see the generated HTML code. Is there a way to expand it all or get a plain text file?
I just accidentally found out that there doesn't even need to be Firebug. We can just press CTRL-A (to select all) on the webpage, and then right click and choose "View Selection Source", then we will get a plain text file of the "current HTML code", even will see a <div> that is the Firebug panel that is before the <body> tag if Firebug is open. But it seems like a weird way to invoke this. Is there any other way?
(Update: generated HTML usually refers to the HTML after JavaScript changes the DOM. It is the current DOM tree instead of the original source code)
In Firebug's HTML tab, right-click the root node and select "copy HTML". Then paste to a text editor.
Without Firefox Add-Ons, you could use a bookmarklet like this:
javascript: var win = window.open(); win.document.write('<html><head><title>Generated HTML of ' + location.href + '</title></head><pre>' + document.documentElement.innerHTML.replace(/&/g, '&').replace(/</g, '<') + '</pre></html>'); win.document.close(); void 0;
With the Web Developer toolbar add-on, select View Source - View Generated Source. And if you want to view the original source, select View Source - View Source (or simply press CTRL-SHIFT-U)
Using the Firefox DevTools (integrated in FF since version 35) you can view the generated HTML opening the web inspector (CTRL-shift-C) and selecting the HTML tab.
You can copy the generated HTML by right clicking on <html> and selecting Copy inner HTML.
If you're looking for a programmatic solution, you can just feed the document into an XMLSerializer.
I don't know if I understood your question well, but here is something really simple and you won't need another addon.
Every browser has a native function to view the source-code of the actual page, just right-click and look for something that resembles "source" or "code".
In Firefox for example it's just "Souce-code", in Chrome it is "View Page Source" and so on.
That being said, Web Developer toolbar is indeed a great addon, especially if you do CSS too.

Resources