Facing problem to work with Safari,Chrome Browser for Selenium RC with Junit

1,174 views
Skip to first unread message

Sravani Boyapati

unread,
Sep 12, 2012, 8:06:41 AM9/12/12
to seleniu...@googlegroups.com
Hi all,
         This is Sravani, hope you guys are doing well.
I am facing problem with the browsers chrome and safari, i have tried with *chrome, *googlechrome, *safari.

I am running the scripts on ubuntu 11.0 with selenium rc & junit. For firefox it was working fine.

But still i haven't get any solution for this issue. For Chrome I am getting issue that " Selenium Can't find the server at selenium-server. For Safari i am getting this issue
Got result: Failed to start new browser session: java.lang.RuntimeException: Safari could not be found in the path!
Please add the directory containing ''Safari'' to your PATH environment
variable, or explicitly specify a path to Safari like this:
*safari /blah/blah/Safari on session null

Could you guys help in this. I am sending the code for clear understanding. Here in the code itself i need to change something.
Please help in this...issue

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

// First Scenario in Test Scenarios
public class Google_Login {
    public SeleniumServer ss;
    public Selenium selenium;
   
    @Before
    public void beforetest()throws Exception
    {
        ss=new SeleniumServer();
        ss.start();
        selenium = new DefaultSelenium("localhost",4444,"*googlechrome","http://");
        selenium.start();
    }
    @Test
    public void testopenfacebookurl() throws Exception
    {
        selenium.open("http://www.google.com");
        selenium.windowMaximize();
        selenium.type("gs_htif0","selenium");
        selenium.click("gbqfba");
       
    }
    @After
    public void aftertest()throws Exception
    {
      selenium.stop();
      ss.stop();   

    }

}

Thanks a lot in Advance


--
Sravani.Boyapati

Mike Riley

unread,
Sep 12, 2012, 2:49:13 PM9/12/12
to seleniu...@googlegroups.com
It has been a while, but I believe you want googlechrome without the asterisk.  I also am not sure you can use safari with RC, but then I have never tried.

Mike

Darrell Grainger

unread,
Sep 12, 2012, 2:51:18 PM9/12/12
to seleniu...@googlegroups.com
Selenium Server has code to hunt for the web browser executables. For example, it may look in "C:\Program Files\Apple\Safari\bin" for the safari.exe file. For each platform (Windows, Mac OS X, Linux) it looks in various places for the web browser executable. If it does not find it in the common locations it will try to run it without an absolute path. This means the browser executable MUST be in our path. If you open a terminal (xterm) on your ubuntu system and enter "safari" to run the browser, it should run Safari. If it does not then you need to change your path to include the directory safari is located OR add a link to safari in a directory which is in your path.

For Chrome, it uses a Chrome Driver Server. Before Selenium Server would launch the Chrome web browser. Now, Selenium Server launches a Chrome Driver Server (http://code.google.com/p/chromedriver/downloads/list) and the Chrome Driver Server launches the Chrome web browser. If the Chrome Driver Server is not in your path, launching Chrome will fail.

Also, DefaultSelenium is based on the Selenium interface. This is Selenium 1.x and not really being actively developed. It is still supported and will work with older web browsers but every new release of Selenium seems to make the Selenium 1.x code less and less viable.

You really want to start using the WebDriver interface, implemented in FirefoxDriver, ChromeDriver, SafariDriver and HtmlUnitDriver as it is actively supported. The Selenium interface is not being updated to support current versions of the web browsers. For example, Selenium will work with Firefox 3.6 but not 14.0. To write tests for Firefox 14.0 you need to use WebDriver.

Anji Prassana

unread,
Sep 13, 2012, 4:38:21 AM9/13/12
to seleniu...@googlegroups.com
Hi sravani,
   Hope, What Darell commented here might have answered your question.One more thing is,
 For IE and ChromeDriver, we've a separate executable driver files as darell said IEDriverServer.exe and ChromeDriverServer.exe for chrome. You need to download these Drivers and copy in your system.Later, in your script, before you instantiate your browser instance, use the below line..
 System.setProperty("webdriver.chrome.driver","/usr/lib/chromerDriverServer.exe");
 // I am assuming that you were copied the downloaded exe in /usr/lib path.If it's some other, change is accordingly. Then, Create Driver instance like,
 Webdriver driver=new ChromeDriver();
 driver.get("<URL>");
.
.
.
.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/r6-RCO8b9vkJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Thanks&Regards
Anjaneyulu P
"The way you see the things is the way to think and is the way you react upon!!"

Sravani

unread,
Sep 14, 2012, 5:06:09 AM9/14/12
to seleniu...@googlegroups.com, anji...@yahoo.co.in
Hi Anji and Selenium group,
I tried with the one whatever you had suggested me that System.setproperty("webdriver.chrome.driver","usr/bin/chromedriver.exe"). But when i tried with this path iam getting this error.
Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: /home/sravani/Project_Automation/usr/bin/chromedriver.exe
I had downloaded the chromedriver.exe and i put the same .exe file in usr/bin but my problem has not been solved.
Actually iam new to web driver, so i am asking these type of doubts. so dont mind for these doubts. could you please help in that because i cannot understand what will be the problem.
My simple doubt is what the command do that system.setproperty It only sets the path or we need to keep the .exe file in particular path.

Could you please help in this doubts clearly
 Please help me in that ASAP.


Thanks in Advance


Regards
Sravani

Krishnan Mahadevan

unread,
Sep 14, 2012, 7:01:00 AM9/14/12
to seleniu...@googlegroups.com
Can you please check what is the "absolute file path" of your chromedriver.exe ?

For IE : You would need to provide the directory where the IEDriverServer.exe resides.
For Chrome : You would need to provide the absolute file path of your chromedriver.exe

When you specify it as : System.setproperty("webdriver.chrome.driver","usr/bin/chromedriver.exe")

What you are essentially telling here is, from your project's current directory, the chromedriver.exe can be found in usr/bin

This is making WebDriver search for it here : /home/sravani/Project_Automation/usr/bin/chromedriver.exe

Is this the place where your binary resides ?


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/N_pNAQQ9bDkJ.

Mike Riley

unread,
Sep 15, 2012, 7:35:00 PM9/15/12
to seleniu...@googlegroups.com, anji...@yahoo.co.in
That looks like a Linux home directory path.  Chromedriver.exe is only for Windows.  Are you using Linux?

Mike
Reply all
Reply to author
Forward
0 new messages