Selenium

Apart from Technical Topics, increasingly i find myself wanting to write about other topics that interests me - Entreprenuership and Business, Leadership, Africa, Service Industry (e.g Hotels, Restaurant). My writings would always represent my opinions and it might change from time to time.

Could not start Selenium session due to browser url not including http

I was helping a friend out last weekend, and he was getting an error java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Error while launching browser at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89) This was strange because looking at his code everything seem to be properly set up, i did some debugging and I discovered that the session in the selenium object was null, this suggested that we weren’t initializing the selenium object properly.

could not start Selenium session: Failed to start new browser sesion

I have heard people have problems with starting firefox3 while using selenium1.0.x on windows7. The exact error message is similar to this: java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path! Please add the directory containing “firefox.exe” to your PATH environment variable, or explicitly specify a path to Firefox 3 like this: *firefox3c:\blah\firefox.exe at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89) I attempted to fix this by putting the path in the environment variable of the windows7 machine and it still did not work.

selenium.open timeouts for strange reasons

Have you ever been in situations when your selenium RC test times out after the selenium.open command, the page is loaded but selenium just tells you that it has timed out after 30000ms. I had same problem in Java today when i got the selenium RC 1.0.3 and i fixed the problem by setting the selenium timeout to be “0”. so i have done @BeforeClass public void setUp(){ selenium = new DefaultSelenium(“localHost”, 4444, “*iexplore”, url);

selenium failed to start browser in iexplore mode when selenium server is started dynamically in code

In a previous post, i have written about how i have been starting/ stoping the selenium server dynamically. What i didnt mention was that i was not able to run my tests using Internet Explorer. I got this error 11:56:55.272 INFO - Command request: getNewBrowserSession[*iexplore, http://localhost:8080, ] on session null 11:56:55.272 INFO - creating new remote session 11:56:55.381 INFO - Allocated session 688eff769c8b4751b5fb9477bba213f3 for http://localhost:8080, launching... 11:56:55.397 ERROR - Failed to start new browser session, shutdown browser and clear all session data java.

Search for a single digit within a string using regex as provided in java api

In my current work, i have been writing a lot of test in Java, which obviously means i need to learn a lot more about the Java api, which is good i think????? Well i needed to match the single digit in this string “home-area-1” and return this digit. With a quick google i found this piece of code here. Pattern p = Pattern.compile(“a*b”); Matcher m = p.matcher(“aaaaab”); boolean b = m.

Start the Selenium Server dynamically

I have been working on a test suite in java using testng as the testing framework. I could not have suggested any other test frame work as it allows me to do a lot of configurable setups and teardowns. Yeah am not gonna promote testng anymore, lol. I could have started using selenium server using a usual batch file that maven could call in one of its targets but i think doing it this way is cleaner.

Setting user extensions when the Selenium Server has been started dynamically

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.

Selenium Remote cant start firefox session due to lock on file

>I am sure you have on this page, because you have run into problem with selenium not been able to run due to a lock on some profile files. Yes, you know what the error is. I really found useful two blogs here and here. However, inas much as i don not want to repeat what has been saidin the blogs i would paste and quote what i found useful and explain a little bit more.

Selenium Test execution speed on Safari vs Internet Explorer

I have been working on a selenium test suite that contains about 150 tests. These test would normally take about 4hrs 30mins for it to execute to completion. I tried to run same tests on Safari today, and it took exactly 1hr 9min. This is such a big difference and i think it is because of the extreme use of Xpath in the test suite. And as it is known thatXpath execute soooo slow in IE.

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’)!