I hope this helps someone someday, I needed to set user extension for a selenium test suite, dynamically in the code as i was starting the Selenium server via same.
public void startSeleniumServer(String port) {
rcc = new RemoteControlConfiguration();
rcc.setPort(Integer.parseInt(port));
try {
seleniumServer = new SeleniumServer(false, rcc);
seleniumServer.start();
} catch (Exception e) {
throw new IllegalStateException("Can't start selenium server", e);
}
}
public void stopSeleniumServer() {
if (seleniumServer != null) {
seleniumServer.stop();
}
}
i was setting the user extension file using the remoteControlConfiguration object
so i had typed:
rcc.setUserExtensions(new File({path_location_to_user_extension.js}));
This didnt work and an extensive search in the api wasnt very useful.
A colleague however found out that doing a
seleniumServer.boot(); would make the user-extension file to work.
Great isn't it ...........
My blog has moved!
You should be automatically redirected in 5 seconds. If not, visit
http://samueladesoga.wordpress.com
and update your bookmarks.
Showing posts with label Javascipt. Show all posts
Showing posts with label Javascipt. Show all posts
Monday, 16 November 2009
Wednesday, 25 February 2009
Waiting for Elements in an IFrame on a WebPage to Load
Waiting for a page to load while writing selenium scripts is pretty straightforward using the
selenium.WaitForPageToLoad("timeout") timeout is time in millisecond.
Sometimes using this command doesn't work, especially when you the whole page is not loaded or reloaded but a popup is loaded in a div on the page. In situation like this i would used the
selenium.WaitForCondition("ScriptToReturnwhich ReturnTrue OrFalse", "timeout");
e.g. of scripts would be
selenium.WaitForCondition(selenium.browserbot.get CurrentWindow().document
.getElement ById('idOfElement ToBelocated')!=null", "60000");
This has always worked well for well until today, i had a special case where the element that i needed to wait for it to load was inside an IFrame, which is loaded within a parent page. Using the Wait for condition as above kept timing out as the Javascript could not access the IFrame.
what worked for me after several hours of trying is:
selenium.WaitForCondition("selenium.browserbot.getCurrent Window()
.frames['Name Of IFrame'].document.get Element ById
'idOfElement ToBelocated')!= null", "60000");
This brilliantly eliminated my nightmare .......
Comments are welcome
selenium.WaitForPageToLoad("timeout") timeout is time in millisecond.
Sometimes using this command doesn't work, especially when you the whole page is not loaded or reloaded but a popup is loaded in a div on the page. In situation like this i would used the
selenium.WaitForCondition("ScriptToReturnwhich ReturnTrue OrFalse", "timeout");
e.g. of scripts would be
selenium.WaitForCondition(selenium.browserbot.get CurrentWindow().document
.getElement ById('idOfElement ToBelocated')!=null", "60000");
This has always worked well for well until today, i had a special case where the element that i needed to wait for it to load was inside an IFrame, which is loaded within a parent page. Using the Wait for condition as above kept timing out as the Javascript could not access the IFrame.
what worked for me after several hours of trying is:
selenium.WaitForCondition("selenium.browserbot.getCurrent Window()
.frames['Name Of IFrame'].document.get Element ById
'idOfElement ToBelocated')!= null", "60000");
This brilliantly eliminated my nightmare .......
Comments are welcome
Saturday, 31 January 2009
Need to get a value of an attribute using selenium
I was in this situation when i needed to get the value of an html attribute and i found the selenium.getattribute very handy .....
Okay the scenario was such that there was an element which is collapsible on the page and the only attibute for that element that indictated the status of the collapsible element was the 'Class'. when the element was collapsed, the value of the class attribute was 'asleep' and when the element was expanded, the value of the class atttribute was 'awake'.
The script used to determine the status of this element is
Okay the scenario was such that there was an element which is collapsible on the page and the only attibute for that element that indictated the status of the collapsible element was the 'Class'. when the element was collapsed, the value of the class attribute was 'asleep' and when the element was expanded, the value of the class atttribute was 'awake'.
The script used to determine the status of this element is
selenium.GetAttribute("elementLocator@nameofAttribute");
so if the id of my element is FundingClass and the attribute we are interested in is the 'Class'
The selenium code will be
selenium.GetAttribute("FundingClass@Class");
Hope this helps someone .....
Subscribe to:
Posts (Atom)