Wednesday, 19 June 2013

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session.

 This type of error will come just in case

1) if you script unable to find xpath which  you have specified.

To trobleshoot this error .. run your script on Debug mode. So that you will come to know.. where it is failing.
2) just in case if you are driver is close before performing your operations in that case also this error will come.




org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.31.0', revision: '1bd294d185a80fa4206dfeab80ba773c04ac33c0', time: '2013-02-27 13:51:26'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_21'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:161)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
    at com.mns.international.framework.WebDriverLoader.initializeWebDriver(WebDriverLoader.java:61)
    at testsuites.MyFirstTest.beforetest(MyFirstTest.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.rules.Verifier$1.evaluate(Verifier.java:34)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner

Monday, 17 June 2013

Proxy settings for Remote Webdriver Remotewebdriver

if (browser1.equalsIgnoreCase("firefox")) {

capability = new DesiredCapabilities().firefox();
capability.setBrowserName(browser1);
capability.setJavascriptEnabled(true);

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();

String hostname = "proxybc.youcompany.net:8080";
String username = "changeUserid";
String password = "Password1";


proxy.setProxyType(ProxyType.MANUAL);
proxy.setHttpProxy(hostname);
proxy.setSslProxy(hostname);
proxy.setFtpProxy(hostname);
proxy.setSocksUsername(username);
proxy.setSocksPassword(password);




FirefoxProfile fp = new FirefoxProfile();
fp.setProxyPreferences(proxy);
capability.setCapability(FirefoxDriver.PROFILE, fp);
driver = new RemoteWebDriver(new URL("http://"
+ ConfigReader.SELENIUM_SERVER_URL
+ ":".concat(port).concat("/wd/hub")), capability);
browser = new WebDriverBackedSelenium(driver,
ConfigReader.ENVIRONMENT_URL);

jse = (JavascriptExecutor) driver;

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

Saturday, 15 June 2013

How to find or search file name in Eclipse or short cut to find file name in eclipse

Please use below keyboard keys to find any character or string in eclipse .


Ctrl +Shift + R

After pressing this command ... Open Source popup window will come.

Monday, 10 June 2013

Java was started but returned exit code=1

For this we have to go to Command line

type

c:\> java -version
then you can find some error like
Error occurred during initialization of VM. I could not find agent library jvmhook on the library path, with error: %1 is not a valid Win32 application.

So now you have go to Control panel-> System -> Environment variables

Under "System Variable" tab you can find
JAVA_TOOL_OPTIONS

Delete that one and click on ok

Now again go to c:\> java -version

Now it will work fine.

Your eclipse problem also will resolve.






Eclipse.ini
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120522-1813
-product
com.android.ide.eclipse.adt.package.product
--launcher.XXMaxPermSize
256M
-showsplash
com.android.ide.eclipse.adt.package.product
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms512m
-Xmx1024m
-Xss1024k
-Declipse.buildId=v21.0.0-519525

Saturday, 8 June 2013

How to switch IE versions in browsers

To change IE Internet Explorer versions in browser. We have to press F12 on keyboard .

And after that change your IE version from IE 8 to IE 9 ... As per your requirement.