Showing posts with label Selenium. Show all posts
Showing posts with label Selenium. Show all posts

Wednesday, May 25, 2011

how to start server with proxyInjectionMode option from the code

The below code can be used to start the server from the java code

RemoteControlConfiguration config = new RemoteControlConfiguration();
config.setProxyInjectionModeArg(true);
SeleniumServer server = new SeleniumServer(config);

Friday, May 20, 2011

Selenium commands to get browser name, browser version , operating system and few more

Browser name : selenium.getEval("navigator.appName;") returns the name of the browser.

Browser code name : selenium.getEval("navigator.appCodeName;") returns the code name of the browser.

Browser version : selenium.getEval("navigator.appVersion;") - The appVersion property is supported in all major browsers and it returns the version of the browser.

Browser and Operating system : selenium.getEval("navigator.userAgent;") - This property returns the value of the user-agent header sent by the browser to the server.

Whether Java Enabled : selenium.getEval("navigator.javaEnabled();") - returns a Boolean value that specifies whether the browser has Java enabled.

selenium.getEval("navigator.platform();") - returns for which platform the browser is compiled

Check Cookie Enabled or not : selenium.getEval("navigator.cookieEnabled();") - returns a Boolean value that specifies whether cookies are enabled in the browser.

Wednesday, May 18, 2011

Any solution for this problem "Cache Access Denied"

ERROR

Cache Access Denied


While trying to retrieve the URL: http://www.thecheesecakefactory.com/

The following error was encountered:

  • Cache Access Denied.

Sorry, you are not currently allowed to request:

    http://www.thecheesecakefactory.com/
from this cache until you have authenticated yourself.

You need to use Netscape version 2.0 or greater, or Microsoft Internet Explorer 3.0, or an HTTP/1.1 compliant browser for this to work. Please contact the cache administrator if you have difficulties authenticating yourself or change your default password.

I have cleared all the cache and worked on the proxies too , but not able to solve this .. Any answers please

Monday, May 16, 2011

StaleElementReferenceException while running Selenium2 WebDriver

For the last one day i have started working on WebDriver and the first issue that came for me was the StaleElementReferenceException . My example was simple , ie do a google search for a word and click on submit .

First time , it worked ..Added some more commands i started getting this exception org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM

Reasons for this issue was due to the faster load of the page .Kept a Tread.sleep command and it worked .

As thread.sleep is not a good way of programming , i used

WebDriverWait wait = new WebDriverWait(driver, 10);


When i searched a bit more , found one more way to make it wait ,

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS)


called impilicit way of waiting which also worked...

WebdriverWrapper and WebElementWrapper can also be used which will get the new WebElement Object .

Wednesday, April 27, 2011

Selenium and self-signed SSL Certificates(https)

For quite some time , i have postponed this task of running my product in https mode and add this part in the selenium framework we have designed.

The following is my learning in this part . Though half baked (yet of find an answer for this in IE) , it might be useful for someone .

Basic of selenium RC , ie starting a new firefox profile everytime and so we will be loosing the https added certificates which we have stored by default . The best workaround is to create a new custom firefox profile , add the exception to it . And use this firefox profile to start the selenium session.

Following blog posts would be well suffice to do get it work on this workaround

http://jktechtrip.wordpress.com/2011/04/14/selenium-and-self-signed-ssl-certificates-in-firefox-java-linux/

  1. Close down any running Firefox instances.
  2. Start Firefox (the one you're going to run your tests with) with the profile manager: firefox -ProfileManager
  3. Create a new profile. You'll be prompted to choose a directory for the profile. Put it somewhere inside the project where you're writing the tests.
  4. Select the profile and run Firefox using it.
  5. Browse to the HTTPS URL (with self-signed certificate) you're going to be testing against.
  6. Accept the self-signed certificate when prompted. This creates an exception for it in the profile.
  7. Close the browser and go to the Firefox profile directory.
  8. Copy the files cert_override.txt and cert8.db files in the new firefox custom profile directory
  9. When you run your Selenium server (like in my Ant example above), pass a -firefoxProfileTemplate /path/to/profile/dir argument to it. This tells Selenium to use your partial profile (with certificate exceptions) as a basis for minting its new profile. So you get the certificate exceptions, but without any of the other clutter you would get if you used a whole profile. Ie java -jar selenium-server.jar -firefoxProfileTemplate “

You can check for the newly created firefox profile at

C:\Documents and Settings\Administrator\Application Data\Mozilla\Firefox\Profiles\hpgmv92o.testprofile (This will change based on the location u create ur profile)

Info : cert_override.txt is a text file generated in the user profile to store certificate exceptions specified by the user. This file is used by Firefox, Thunderbird, and other XUL-based applications.

Why is that trustAllSSLCertificates flag can't be used . Yup the following blogpost tells you in detail how to use that

http://mogotest.com/blog/2010/04/13/how-to-accept-self-signed-ssl-certificates-in-selenium

For a long time , i was searching for a answer to find a way how to start selenium in IE in https mode . But still not have found a way . Comment and say if you have an answer for this

Friday, April 15, 2011

How to declare browsers in Selenium

Following are the Supported browsers of Selenium

Firefox
Internet Explorer
Google Chrome
Safari
konqueror
Opera

Firefox browser declaration itself is of 7 different types , firefox , chrome , firefox2, firefox3,firefoxproxy, firefoxchrome and pifirefox . There is no much difference in using firefox, chrome , firefoxchrome ,firefox2 and firefox3 . All these have a common functionality .


firefox -FirefoxLauncher
chrome - FirefoxChromeLauncher
firefoxchrome - FirefoxChromeLauncher
firefox2 - Firefox2Launcher
firefox3 - Firefox3Launcher
firefoxproxy - FirefoxCustomProfileLauncher
pifirefox = ProxyInjectionFirefoxCustomProfileLauncher

iexploreproxy = InternetExplorerCustomProxyLauncher
iehta = HTABrowserLauncher
iexplore = InternetExplorerLauncher
piiexplore = ProxyInjectionInternetExplorerCustomProxyLauncher

opera = OperaCustomProfileLauncher

safari = SafariLauncher
safariproxy = SafariCustomProfileLauncher

konqueror = KonquerorLauncher
mock = MockBrowserLauncher
googlechrome = GoogleChromeLauncher

Iexplore,Chrome are for basic IE launchers .

Firefox , firefox2 , firefox3 ,firefoxchrome are basic for Firerox .Where firefox2 and firefox3 are specific for Firefox versions 2 and 3 respectively.

iexploreproxy , firefoxproxy and safariproxy are launchers for IE , Firefox and Safari under proxy injection mode In proxy injection mode, the selenium server is a proxy for all traffic from the browser, not just traffic going to selenium-server URLs. The incoming HTML is modified to include selenium's JavaScript, which then controls the test page from within

Monday, April 11, 2011

Difference between seleniumserver.boot() and seleniumserver.start()

when you use .boot() your user-extensions.js is invoked too, which is not the case when you use .start() .

Seleniumserver.boot internally calls Selenium.server ..So using boot and start in same code means like trying to start the server twice .

Sunday, April 10, 2011

Why Name Selenium

I was wondering all this time why Selenium Testing Tool name clashes with chemical element "Selenium" having atomic number 34 . Seems i got an answer now . Jason Huggins started selenium in 2004 in order to find an alternative to QTP and selenium mineral supplements serve as a cure for mercury poisoning ..Hence he choose the name Selenium .

Dont know whether it is good or bad , but Selenium Testing tool dominates Selenium element in google search results in the top ten (7 : 3)