What is the difference between Selenium core extensions and Selenium IDE extensions? - selenium

I know that for using my js file I must use Selenium Core extension but I cannot understand what Selenium IDE Extension field is for?
Thanks in advance.

Selenium extensions provide a way to add more functionality/feature to Selenium as per your requirements. This is also known as Selenium User-Extensions and Selenium Custom-Extensions.
The concept is pretty simple, extend Selenium by adding your own actions, assertions and locator-strategies. Add JavaScript methods to the Selenium object prototype and the PageBot object prototype. On startup, Selenium will automatically look through methods on these prototypes, using name patterns to recognize which ones are actions, assertions and locators.
User-Extensions can be used with Selenium IDE (see this) and Selenium RC (see this).
Do not get confused with different names. Same concept is getting used at different places, differently.

"Selenium IDE Extensions" is mainly used to extend the recording behavior of Selenium IDE.
To use the extensions
Copy the extension code into a new .js file. You can place it
anywhere on your disk.
Open Options - Options... in the menu bar.
Choose the saved file in "Selenium IDE extensions" field and click OK.
Restart Selenium IDE by closing the window and opening it again.
Example
By default, Selenium IDE only records click events on certain types of elements (e.g. , , ...).
You can record any click events occured in a page by putting the following code as Selenium IDE extension.
Recorder.removeEventHandler('clickLocator');
Recorder.addEventHandler('clickLocator', 'click', function(event) {
if (event.button == 0) {
this.clickLocator = this.findLocator(event.target);
}
}, { capture: true });

Related

How can itegrated AutoIT in WebDriver (Selenium Grid) ?

I'm launched Selenium Grid (Node and Hub),and testing Web app. But I need provide some action on Windows Open dialog. Can I do that with and how using AutoIt on next way : capabilities.setCapability("browser", "AutoIt") ?
Refer this link for step by step guide on how to use AutoIT with Selenium. This involves using the tool to create a .au3 script which you will need to execute from your code. But from your question, if you want something like capabilities.setCapability("browser", "AutoIt"), you have to use AutoItDriverServer (See README for installation steps).
Its a Selenium like Interface wrapper for AutoIt, so you can basically operate your windows application by the very same selenium methods you are familiar with.
How to Use it:
In the 'autoitdriverserver_python' directory, run the "server.py" file. Now, whenever you want to perform actions on your windows application, just create a new remote driver with capability of 'browserName':'AutoIt'. Ex-
driver = webdriver.Remote( command_executor='http://127.0.0.1:4723/wd/hub', desired_capabilities={'browserName':'AutoIt'})
driver.get("path to your application")
driver.switch_to_window("window name")
driver.find_element_by_id("your id").click()
Note as mentioned in docs:
AutoIt doesn't find or handle multiple elements specified by location
strategy, therefore, finding elements in WebDriver is not implemented
for AutoItDriverServer. You can only find singular elements.
See this link for all the available commands. To locate elements, for example through ID, you need AutoIT info tool which is available in the entire package.

Automate a button click on chrome://extensions page using selenium webdriver

I'm trying to write an automated test that will automate the process of updating a google chrome extension. I'm not aware of another method of doing this automatically so here is what I'm currently trying to do:
Open the chrome extensions page (as far as I'm aware this is just an html page unless I'm missing something).
Click on the "Update extensions" button
Here is what I have tried having opened the chrome extensions page:
IwebElement UpdateButton = driver.findelement(By.Id("update-extensions-now"));
UpdateButton.Click();
For some reason the button click is not registering. I have tried some other locators such as CSS path and Xpath but they don't work either. Also, when I debug this test, it passes fine so I know it's not an issue with any of my locators. I have (as a test) tried to automate clicks on the other elements on this page and it's the same issue. I can't get a handle on any elements on the chrome://extensions page at all.
Has anyone encountered this or have any ideas as to what's going on?
You can use the Chrome extensions API to auto-update required extension.
Find the file "manifest.json" in the default Google Chrome
C:\Users\*UserName*\AppData\Local\Google\Chrome\User Data\Default\Extensions
There find the update URL of your extension:
{
"name": "My extension",
...
"update_url": "http://myhost.com/mytestextension/updates.xml",
...
}
The returned XML by the Google server looks like:
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='yourAppID'>
<updatecheck codebase='http://myhost.com/mytestextension/mte_v2.crx' version='2.0' />
</app>
</gupdate>
appid
The extension or app ID, generated based on a hash of the public key, as described in Packaging. You can find the ID of an extension or Chrome App by going to the Extensions page (chrome://extensions).
codebase
A URL to the .crx file.
version
Used by the client to determine whether it should download the .crx file specified by codebase. It should match the value of "version" in the .crx file's manifest.json file.
The update manifest XML file may contain information about multiple extensions by including multiple elements.
Another option is to use the --extensions-update-frequency command-line flag to set a more frequent interval in seconds. For example, to make checks run every 45 seconds, run Google Chrome like this:
chrome.exe --extensions-update-frequency=45
Note that this affects checks for all installed extensions and apps, so consider the bandwidth and server load implications of this. You may want to temporarily uninstall all but the one you are testing with, and should not run with this option turned on during normal browser usage.
The request to update each individual extension would be:
http://test.com/extension_updates.php?x=id%3DyourAppID%26v%3D1.1
You can find even more detailed information on exntesions developers site: https://developer.chrome.com/extensions
If you look at the HTML of the "chrome://extensions" page you will notice that the "Update extensions now" button is contained within an iframe. You need to switch to the iframe before trying to register a button click. i.e:
(This is in c#. Note that this code is written from memory so it may not be 100% accurate. Also, you will want to write more robust method. This code just quickly demonstrates that by switching to the iframe, it will work ok)
String ChromeExtensionsPage = "chrome://extensions";
driver.Navigate().GoToUrl(ChromeExtensionsPage);
driver.Switchto().Frame("DesiredFrame");
IwebElement UpdateButton = driver.findelement(By.Id("DesiredButtonID"));
UpdateButton.Click();

Element not being added when running test through webdriver

I am working on writing a story for a bdd framework which uses jbehave/selenium/webdriver and am having a problem where the test encounters an error while running the story but appears to be fine when running manually. I'm having a problem where javascript for the functionality I'm testing behaves slightly different when I'm running tests manually on firefox vs through selenium web driver on the same system/version of firefox and this difference is causing a js error.
I've debugged and basically the root of the problem appears to be that var request_XML_container = $('div_appendpoint_id'); returns something different when I'm running the test manually vs when I run through the bdd framework.
var request_XML_container = $('div_appendpoint_id');
request_XML_container.innerHTML = encoded_xml_from_request;
var pos = method_to_get_position('id_of_place_div_should_be_appended_to');
// JS exception is thrown saying that style is not defined **ONLY**
// when running through web driver. Running test manually on
// same system and same browser works fine.
request_XML_container.style.left = (pos[0] - 300) + 'px';
request_XML_container.style.top = (pos[1] + 25) + 'px';
request_XML_container.style.display = "block";
Why this would work fine when running manually that var request_XML_container = $('div_appendpoint_id'); would return an item with style defined, but when running through webdriver that the style attribute of the element would not be defined?
UPDATE: I had originally thought that this was updating an iframe, but I read the markup wrong and the iframe I saw is a sibling - not a parent - of the element where the response is being appended to. I'm trying to simply append the response to a div. To be honest, this only makes things more confusing as grabbing a div by id should be pretty straight forward and I'm now sure why webdriver would be producing a different return element in this situation.
UPDATE 2: Steps to reproduce and information about the system I'm on:
Use webdriver to navigate to this url: http://fiddle.jshell.net/C3VB5/11/show/
Have webdriver click the button. It should not work
Run your test again, but pause put a breakpoint at your code to click the driver
Click the button on the browser that webdriver opened. It should not work
Refresh the browser page on the browser that webdriver opened. Now, it should work.
System details:
OS : OS X 10.8.5 (12F37)
IDE : Eclipse Kepler: Build id: 20130614-0229
Browser (used manually and by webdriver) : Firefox 23.0.1
Selenium version: 2.35.0
UPDATE 3: I have provided this maven project on github to aid in reproducing: https://github.com/dkwestbr/WebdriverBug/tree/master/Webdriver
Synopsis/tl:dr; Basically, in certain situations it appears as though webdriver is overwriting the '$()' javascript method with a method that does not return an HTMLElement with innerHTML or style defined (among other things). This post details the issue and how to reproduce.
I have opened this ticket to track the issue: https://code.google.com/p/selenium/issues/detail?id=6287&thanks=6287&ts=1379519170
I have confirmed that this is a bug with the Thucydides framework (understandable since they still aren't at a 1.0 release).
Issue can be tracked here: https://java.net/jira/browse/THUCYDIDES-203

issues in running selenium in internet explorer

Hi I am trying to run my selenium webdriver on IE9.
WebDriver version : 2.32.0
IE:9
IEDriverServer_win32:2.32.3
windows7
Below is my code:
File IEDriver=new File(System.getProperty("user.dir")+File.separator+"BrowserDrivers"+File.separator+"IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", IEDriver.getAbsolutePath());
DesiredCapabilities cap=DesiredCapabilities.internetExplorer();
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver=new InternetExplorerDriver(cap);
driver.get("http://in00616:8421/GS");
Thread.sleep(3000);
//driver.findElement(By.id("j_username")).sendKeys("admin");
//driver.findElement(By.id("j_password")).sendKeys("admin");
driver.findElement(By.xpath(".//input[#id='j_username']")).sendKeys("admin");
driver.findElement(By.xpath(".//input[#id='j_password']")).sendKeys("admin");
driver.findElement(By.id("login")).submit();
Thread.sleep(2000);
driver.findElement(By.xpath(".//button[text()='Securities']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath(".//span[text()='Issue']")).click();
Thread.sleep(2000);
driver.findElement(By.id("tabSecurities_Issue_Request_for_Issues")).click();
Above code logs in to my site but then when I try to click on Securities button I am not able to do it. Securities button starts flickering and then I am notified that unable to find the element.
Exception in thread "main" org.openqa.selenium.NoSuchElementException:
Unable to find element with xpath == .//span[text()='Issue Type']
(WARNING: The server did not provide any stacktrace information) –
Same code works fine in FireFox.
Please help as i am suppose to test my UI on InternetExplorer.
I think it is the version compatibility issue.
Can anyone suggest the compatible version set for IEDriverServer, Selenium WebDriver and IE which is in working condition.
As this SO answer points out, IE does not have native XPath support. Instead, Selenium WebDriver uses an old third party xpath library when IE is being used. Firefox has integrated support for XPath, which is why your selectors work fine in that browser.
I would highly recommend you update your selectors to instead use CSS selectors. They are supported across all browser, are easier to read, understand, and pick up, and they are pretty fast.
You can learn more about how to use CSS selectors from some different tuturials here, here, and here, and a CSS selectors cheatsheet.
Also, whenever possible, please try to not select an element by the text it contains. If you can select an element by its ID, class, other attribute, or even through the DOM chain (i.e. "div.1 > div.2 > span.a > a.b"), is better than trying to select an element by text.
Webdriver has difficulty with IE using locators. It seems like Murnal has difficulty using CSS locator. My advice would be you HAVE to use other locators if one doesnt work. This issue comes again and again while using non firefox browser. In the meantime an easier way to come up with alternate locator is use Firefox selenium IDE, there in the boxes where you type command you will see it gives alternate locator as well. Copy that and try plugging tha in your webdriver's findelement script.
Hi all i have found out that it was the issue of Selenium Webdriver 2.32 with IEDriver_Server2_32. After trying out permutation & Combination with latest available webdriver versions and IEDriver_Server, i have found out suitable stable configuration to work on IE9 below is the stable configuration : Webdriver : 2.33.0 IEDriver_Server : 2.33.0. There is still small issue but i am trying to look for workaround. Issue : In IE if some control's tooltip overlaps other control than IE is not able to find out that control. i guess this issue is with IEs working. IE uses nativeEvents to perform operation hence it is not able to locate that control. In FF it is able to find out that control and it is working fine. Thanks everyone.

Selenium Webdriver hover not working

Selenium Webdriver 2.31.0
with Scala 2.9
Anyone know how to do a mouse hover in Firefox? I'm basically trying to hover over an element to display a tooltip.
This code fails to move the mouse over the element specified.
val webElement = webDriver.findElement(By.cssSelector(myElement.queryString))
val builder = new Actions(webDriver)
val hover = builder.moveToElement(webElement).build()
hover.perform()
I have also tried mouse events without success (as described here WebDriver mouseOver is not working properly with selenium grid)
This is somewhat anecdotal since I don't have an exact technical explanation, but I've experienced this in the past and have remedied by upgrading Selenium.
The first thing I check is to make sure my selenium is up to date. This includes dependencies, standalone-server and browser drivers (though, in this case, not applicable as Firefox is included with Selenium).
Another possible (and more probable) cause, more directly related to Firefox, is Firefox itself. It's been my experience that a Firefox update can, from time to time, break some selenium functions, particularly hovers. I've found that either upgrading selenium, or if no update has been released, downgrading Firefox will solve the problem.
I wish I had more detailed information to give you, but I'm still learning the finer details of this situation myself. If nothing else, I hope this points you in the right direction.
Since you havn't said you got any errors,
After build().perform(), provide a wait method say, Thread.sleep() for certain amount of time, since there are posibilities where mousehover performed in fraction of seconds and it may not be possible to see the tooltip.
Makesure the locator is correct (because you may point to someother locator which doesn't show up any tooltip)
Makesure you firefox supports the mousehover functionality
The code might resemble as same as your's, but give it a try(JAVA),
Actions builder = new Actions(driver);
WebElement we = driver.findElement(locator);
Actions perf= builder.moveToElement(we).build();
perf.perform();
Thread.sleep(1000);
You can look out the link for your ref : #firefox issue
As your issue is in Firefox, you may need to enable Native Events with webdriver, specifically
FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(true);
WebDriver driver = new FirefoxDriver(profile);
I've had to do this to get drag and drop working in Firefox on Unix, although it worked with the same code on a Windows box.