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
Related
Firebug for Firefox had Breakpoints on DOM (HTML) Mutation Events. Firebug was merged into Firefox developer console. I don't find the feature in the Firefox developer console, can someone help me with that?
Found this:
"You set a DOM Mutation Breakpoint in the Page Inspector. Navigate to the DOM node in which you are interested and use the context menu to set the breakpoint."
"
Attribute Modification
Execution pauses when any of the elements' attributes are modified.
"
from
https://developer.mozilla.org/en-US/docs/Tools/Debugger/Break_on_DOM_mutation
It might be just me but I can't find any way to get DOM element's XPATH in Firefox.
That was possible in Firebug, but now it's deprecated in favor of Firefox Developer Tools, and the recommendation is not to use it any longer.
So, is there any way to get XPATH in Firefox and its Developer Tools?
Open the developer tools in Firefox, then:
Click on Console tab.
Type allow paste if you are pasting anything.
Type the XPath like so:
$x("path")
For example:
$x(".//*[#id='4th']/tbody/tr[1]/td")
Firebug also works well, so I suggest using that instead.
This feature is available in the Firefox DevTools since Firefox 56. To copy the Xpath of an element, right-click it within the Inspector and choose Copy > Xpath from the context menu.
In earlier versions of Firefox the option was placed in the first level of the context menu. As more copy options got added, they were moved into the Copy submenu.
Even if there is no extension available for Firbug in Firfox V57/Quantum. Still we can performed same operation which we performed earlier with the help of firebug, in Firefox dev tool now. Firefox dev tool has more advanced function than normal browser. So It will be helpful for UIDesigner or any Developer.Features in Developer Tool-Features in Developer Tool
To install & Download Firefox Developer Tool- Firefox Developer Tool
For XPath: Select any element by right click on it and choose Inspect Element(Q) then element/tag gets highlighted under inspector developer tool. Then Right Click on tag and select Copy=>Xpath or CssPath.
but the xpath or Css provided by above option will not be correct always if application is dynamic or having dynamic ids etc...
So better to use console option/ select console option (Press F12) write allow paste and enter.
For Xpath =>we have to use ($x) example: >>$x("//p") It will gives all p tag.
For Css path=> we have to use ($$) Example: >>$$("p") then Enter It will gives all p tag.
You can get the XPath in Quantum by right-clicking on the element html in Inspector and select Copy > XPath. For eg.
For instance the html below will give you the Xpath as - /html/body/form/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table1/tbody/tr[4]/td1
You can also get an earlier version of firefox using from the release page.
Make sure you disable auto update otherwise your browser will upgrade to new one.
You can also use the X path Add-on https://addons.mozilla.org/nn-NO/firefox/tag/xpath to get the x path
I am using Selenium IDE to test some behavior in my FireFox SDK Add-On. For example, I load a page and determine that the content script is executing at intended. In my plugin, I use simple-prefs to set some user defined preferences.
For example, I would like to load a page and then ensure that if a preference is changed, that the content script received the update and made the necessary changes to the page based on the new setting.
when I try to navigate with Selenium-IDE to the plugin configuration page chrome://mozapps/content/extensions/extensions.xul?type=extensions / about:addons. I am able to use Selenium to select an entry (<richlistitem />), but I cannot click any of the buttons within the entry because they are not part of the XUL dom. I have tried using Selenium to send enter, tab, clicks, double clicks to the appropriate <richlistitem /> but there is no way of interacting with the "inner part" of the item.
I have also tried going down the path of using selenium to modify entries via about:config, however, the area with all of the entires is just an XUL <treechildren /> and you have no way of targeting individual entries.
Is there a convenient way to change addon setting as part of an automated workflow with selenium-ide?
It seems you should use Selenium Web driver , by driver you can set preference
I am learning chrome extension by example. Here is the example I currently learning: http://www.chrome-extensions.net/extensions/mappy/
There are three JavaScript files in this sample project: background.js mappy_content_script.js popup.js.
"mappy_content_script.js" is shown in the Combo box of Scripts tab of Developer Tools.
"popup.js" can be found if I right click the extension icon and choose "Inspect popup".
The problem is I can't debug "background.js" or find it in the Developer Tools. I tried insert "debugger;" in this JavaScript file. I also tried use profiling tool to record the script execution. However, when I click the link of "background.js", a blank page shows up.
Is this a bug of chrome or did I miss something? Thanks
background.js is loaded in the background. To inspect it visit chrome://extensions, find the loaded extension, and "inspect active views" for the background script.
Edit
Below is a screenshot of the chrome extensions page. A click on the link background page opens the background page for this extension.
Additional information
EDIT 2020
Here is how you can see the content scripts and debug,
Nowadays you have to install a Chrome extension to allow you to inspect the view of a page, specifically the Develop and Debug Chrome Apps & Extensions
There is an easy way to access your extension code in DevTool and debug it.
Open the DevTool (e.g. F12) , click on "Sources" tab
then look for "Content Scripts" menu next to Page , Filesystem, Overrides etc.
and click on it .
you should see all active extensions listed there and you can easily add break point to each js code and reload the page to debug through
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.