In my earlier post I have explained how to setup Selenium with Eclipse but there I have utilized example of SugarCRM. So, in order to avoid downloading SugarCRM I thought of writing one more post on the same topic which uses Google as example.
Eclipse is an open source Integrated Development Environment which supports multiple languages. Most of the java developers use Eclipse IDE for software development as it is highly extensible with plug-in system and user friendly. We can add external libraries to build path in order to utilize any external APIs available.
In order to setup Selenium in Eclipse, Selenium-Client-driver needs to be added to the Java build path – – >Libraries
In the below example, we will discuss setting up Selenium in Eclipse Step-by-Step.
For this purpose I will utilize Advanced Google Search example.
- Download the latest Eclipse release from – www.Eclipse.org
- Create a project. In my example -> PracticeCode. (File ->New-> Java Project ->Give name as PracticeCode)
- Create Package under this project ->com.selftechy.parameterization
- Under this package – > create a new class (AdvancedSearch.java)
- Add Selenium-Client-Driver (this needs to be downloaded from www.seleniumhq.org)to Java Build Path of the project:
- Right click project (PracticeCode)
- Click Properties
- Click Java Build Path
- Click Libraries
- Click Add External Libraries
- Select the Selenium-Client-Driver
Open AdvancedSearch.java class and copy the following code:
package com.selftechy.parameterization;
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class AdvancedSearch extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.co.in/");
selenium.start();
}
@Test
public void testAdvancedSearch() throws Exception {
selenium.open("http://www.google.com/");
selenium.click("link=Advanced search");
selenium.waitForPageToLoad("30000");
selenium.type("as_q", "selftechy, selenium, eclipse");
selenium.select("num", "label=20 results");
selenium.click("//input[@value='Advanced Search']");
selenium.waitForPageToLoad("30000");
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}
In the above code we can see “extends SeleneseTestCase” and “import com.thoughtworks.selenium.*;” these two phrases tell Eclipse that we are going to use Selenese commands in the subsequent methods.
In order to run this test case we need to start the Selenium Server first. Follow the steps below to run the Selenium server.
Download Selenium Server from www.seleniumhq.com
Step 1: Create a new text file
Step 2: Open the file and type in following code into it (D:\Workspace-Helios should be changed to the path where selenium-server.jar file is copied)
CD D:\Workspace-Helios
java -jar selenium-server.jar -multiWindow
(Don’t copy and paste as it sometimes adds some special characters)
Step 3: Save it as “Selenium-server.bat”
Step 4: Double click the selenium-server.bat, this should start the selenium server.
Step 4: Still if you are not able to run, then execute both the commands in command prompt (Click Start -> Run ->cmd).
To run the AdvancedSearch.java –> Right click the file and click “Run As” — > JUnit Test
This opens up firefox and executes the test
Hi Seetaram,
I was looking at your blogs for couple of days and found them very useful. Good work keep it up.
Hi
I tried these steps to setting up selenium with eclipse and i tried the google search example. It gives a error like selenium can’t be resolved.
what i do?
I am not understood this issue. Please help me.
Hi
I resolved the issue…. by extends the SelenceTestBase Class.
Thank you….
How can i run this it into the “chrome and ie” can u help me?
change the browser to “*ieexplore” / “*chrome”
It is not working. I changed the browser name as “*chrome” but it is not running. it giving failure message as
java.lang.IllegalStateException: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromium/downloads/list
at com.google.common.base.Preconditions.checkState(Preconditions.java:172)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:86)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:87)
at com.prathibha.parameterisation.CreateAccount.setUp(CreateAccount.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
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.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
In build path i add chromedriver-linux-32.zip. coz I am using Ubuntu 10.10.
Can u please help me.
Will try to help u out… today night will sit on this and find a solution…
i sent u a mail. In that i attached a program in that only chrome browser is opened. then immediately the script is terminated. can u see that once.
package com.prathibha.parameterisation;
import static org.junit.Assert.assertEquals;
import java.io.File;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
public class ChromeTest {
private static ChromeDriverService service;
private WebDriver driver;
@BeforeClass
public static void createAndStartService() throws Exception {
service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File(“/usr/bin/chromium-browser”))
.build();
service.start();
}
@Before
public void createDriver() {
driver = new RemoteWebDriver(service.getUrl(),
DesiredCapabilities.chrome());
}
@Test
public void testGoogleSearch() {
driver.get(“http://www.gmail.com”);
WebElement element = driver.findElement(By.name(“Email”));
element.sendKeys(“Google”);
element.submit();
WebElement button = driver.findElement(By.name(“signIn”));
button.click();
assertEquals(“Google – Google Search”, driver.getTitle());
}
@AfterClass
public static void createAndStopService() {
service.stop();
}
@After
public void quitDriver() {
driver.quit();
}
}
please find what is the issue in it and explain how to resolve it.
/usr/bin/chromium-browser – are you on linux
Yes. I am working on Linux (Ubuntu 10.10).
Hi
Please send me the perticular details with Excel sheet
Thanks
Swamy S
Hi Seetaram,
I’m tried to follow these steps yesterday. I have installed Eclipse Java EE IDE for Web Developers. I downloaded selenium_java-2.5.0.zip and selenium-server-standalone-2.5.0.jar and successfully started the selenium-server-standalone (java -jar selenium-server-standalone-2.5.0.jar -multiWindow). I have several questions/problems:
1. The “import org.junit.*” statement shows an error of “The import org.junit cannot be resolved.”
2. SeleneseTestCase has a line through it and there are several errors on the line:
Multiple markers at this line
– The type SeleneseTestCase is deprecated
– The hierarchy of the type AdvancedSearch is inconsistent
– The type junit.framework.TestCase cannot be resolved. It is indirectly referenced from
required .class files
Also when I was trying to Add Selenium-Client-Driver the procedure I used was slightly different from the instructions you provided. Here’s what I did. Please advise if this is incorrect.
Right click project (PracticeCode)
Click Properties
Click Java Build Path
Click Libraries
Click Add External Libraries <–This option was not available, I clicked Add External JARs and then selected downloaded selenium_java-2.5.0.zip file.
Select the Selenium-Client-Driver
In the Package Explorer, under PracticeCode there is a Referenced Libraries folder that contains the selenium-java-2.5.0.jar with all the com.thoughtworks and org.openqa.selenium packages.
Sorry if this is a very basic dumb question. I would really appreciate any help in getting these issues resolved.
Thanks,
I figured Problem #1 above. Still need help with the deprecated SeleneseTestCase.
“Deprecated” means the API that has been used in the program is being replaced by some other API. Just need to find out the new one and replace the existing in your program.
Hi Cindy,
Nothing is dumb question. I am really glad to help you.
Some of the steps you went wrong.
1. Add External JAR is correct but you needed to unzip the downloaded zip file and then add the jar file. (Eclipse expects JAR file in Add External JAR)
2. In the unzipped folder you can find – Selenium-Client-Driver (names might have been changed in the new Selenium 2.0 version)
3. Need to add Junit.jar file (download the jar file from junit website – just google “download JUnit” and download the jar file) and add using Add External jar
4. Yes. Google has changed the user interface on the Google Search screen – Need to find out the objects that needs to be clicked before going to Advanced Search option
Now SeleneseTestCase is deprecated in the latest release hence we need to use SeleneseTestBase instead
In selenium, how to identify new window which is not having windowId ,WindowName, WindowTitle.
Hi Seetharam,
This blog is really useful for me to get start with eclipse – selenium integration with selenium RC.
Thanks a lot and i’ve started my first execution with the help of your guide.
– Vinodh.R
Hi Seetaram,
Thanx for the extremely useful article. I have faced one problem while trying to automate a website. The website is converted from http://abcd.com to https://abcd.com when trying to login. And the selenium is not able to handle the security message related to ssl certificate. Could you pls help me on this and tell how to resolve this. I think most of the automation testing beginners might be facing the same issue, so an article related to this will also be extremely useful.
Thanks in advance,
Kishor
create a new firefox profile.. that can handle this problem very well…
I need help to setup Selenium Webdriver using Eclipse. Please mhelp me. Thanks.
Hi Seetaram,
I’ve performed above mentioned steps but i’m facing following error on running the project
CODE:
package com.example.tests;
import com.thoughtworks.selenium.*;
import org.openqa.selenium.*;
import org.openqa.selenium.htmlunit.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.ie.*;
import org.junit.*;
import static org.junit.Assert.*;
public class Checkflow {
WebDriver driver;
Selenium selenium;
public void setUp() {
driver = new FirefoxDriver();
selenium = new WebDriverBackedSelenium(driver, “http://IP:8079/”);
}
public void tearDown() {
driver.close();
}
public void testCheckflow() throws InterruptedException {
///some code generated by selenium
}
}
ERROR:
Exception in thread “main” java.lang.RuntimeException: Opera could not be found in the path!
Please add the directory containing opera.exe to your PATH environment
variable, or explicitly specify a path to Opera like this:
*opera c:\blah\opera.exe
at org.openqa.selenium.server.browserlaunchers.OperaCustomProfileLauncher.findBrowserLaunchLocation(OperaCustomProfileLauncher.java:107)
at org.openqa.selenium.server.browserlaunchers.OperaCustomProfileLauncher.(OperaCustomProfileLauncher.java:67)
at org.openqa.selenium.server.browserlaunchers.OperaCustomProfileLauncher.main(OperaCustomProfileLauncher.java:331)
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes;C:\PROGRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar
Please help….
Regards,
Faizan
Thank you for the very helpful blog post.
Thanks Tracey…
I am using Selenium RC to run the Selenium Testcases in java,but I need to run in PHP for dat what i want to do in Eclipse???
You can use Selenium for PHP.. use PHP WebDriver….
k,but i want to use only in selenium RC through php
How to record a autosuggested box in a grid through Selenium IDE
Using selenium IDE, how can we record a thickbox????
I am trying Eclipse / Junit / Selenium web driver / firefox / windows XP . path & CLASSPATH are set . selenium-java-2.25.0.jar , junit.jar are added in the project library . Selnium is running in the background : Example shows below error :
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
at java.net.URLClassLoader$1.run(Unknown Source)
Source code :
package com.selftechy.parameterization;
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class AdvancedSearch extends SeleneseTestBase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium(“localhost”, 4444, “*chrome”, “http://www.google.co.in/”);
selenium.start();
}
@Test
public void testAdvancedSearch() throws Exception {
selenium.open(“http://www.google.com/”);
selenium.click(“link=Advanced search”);
selenium.waitForPageToLoad(“30000”);
selenium.type(“as_q”, “selftechy, selenium, eclipse”);
selenium.select(“num”, “label=20 results”);
selenium.click(“//input[@value=’Advanced Search’]”);
selenium.waitForPageToLoad(“30000”);
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}
NoClassDefFoundError shows that some dependency jar is missing
Hi,
I’ve done all the steps. its working..thank u. but RC doesn’t open the browser and run automation.plz help me..
Hi Seetaram,
This is Hari. I am looking for traning on Selenium. Would you please help me on this?
My email id – harioops@gmail.com
ph – 224 241 0266
Thanks
Hari
I am facing this problem that “selenium can’t be resolved”
please help
This is my first test case-
package com.apms.selenium;
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.server.SeleniumServer;
public class APMS {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium(“localhost”, 4444, “*chrome”, “http://website_address/”);
selenium.start();
}
@Test
public void testUntitled() throws Exception {
SeleniumServer.open(“http://192.167.0.5/”);
selenium.type(“name=Username”, “abcd”);
selenium.type(“name=Password”, “1234”);
selenium.click(“css=input.button”);
selenium.waitForPageToLoad(“30000”);
selenium.click(“//input[@value=’software status’]”);
selenium.waitForPageToLoad(“30000”);
verifyTrue(selenium.isTextPresent(“BV2.10.22.2”));
selenium.click(“css=td.bottom1 > input[type=\”submit\”]”);
selenium.waitForPageToLoad(“30000”);
selenium.click(“//input[@value=’network’]”);
selenium.waitForPageToLoad(“30000”);
selenium.click(“//input[@value=’ACS’]”);
selenium.waitForPageToLoad(“30000”);
verifyEquals(“http://Value”, selenium.getValue(“name=amamamDevice.ManagementServer.URLmamama”));
// selenium.();
selenium.click(“css=input[type=\”submit\”]”);
selenium.waitForPageToLoad(“30000”);
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}
Thank you!
Hi.. I tried running my script with the steps given by you. But I got an error from it and it is
java.lang.NoClassDefFoundError: com/google/common/base/Charsets
at com.thoughtworks.selenium.HttpCommandProcessor.getOutputStreamWriter(HttpCommandProcessor.java:149)
at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:176)
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:118)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:101)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:275)
at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:237)
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:100)
at AdvancedSearch.setUp(AdvancedSearch.java:11)
at junit.framework.TestCase.runBare(TestCase.java:132)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:248)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Charsets
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 23 more
Can you spot me out? Where am I wrong actually?
Thanks for your effort.
Thanks Seetaram such a nice blog about the selenium !! please provide useful materials about the selenium for becoming expert on it.
hai , i want to how to use selenium teting tool in my project
i installed selenium tool rightnow iam working eclipse how to use this tool i dont have any idea for that automation tool plz help
Go through the posts in the blog… everything is self explantory
I am getting this error on Ubuntu 13.04
When running with jUnit
java.lang.NoClassDefFoundError: com/google/common/base/Charsets
at com.thoughtworks.selenium.HttpCommandProcessor.getOutputStreamWriter(HttpCommandProcessor.java:149)
at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:176)
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:118)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:101)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:275)
at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:237)
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:100)
at com.selftechy.parameterization.AdvancedSearch.setUp(AdvancedSearch.java:12)
at junit.framework.TestCase.runBare(TestCase.java:139)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:248)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Charsets
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
… 23 more
java.lang.NoClassDefFoundErro – this exception shows that some dependent jar is missing
Hi Seetaram, I tried executing the above program, it opens the google page in Firefox but errorred out saying “com.thoughtworks.selenium.SeleniumException:ERROR Element link =Advance search not foud.
I commented that line executed it again.
Now i get the below error
“com.thoughtworks.selenium.SeleniumException:ERROR:Element as_q not foud.
Could you please help me out to resolve this?
Can you take some other web application and test? or can you record something by yourself and then try executing it by the Selenium IDE itself?
Hi Seetaram,
This post is really helpful… you are doing a great job
i have added this package in previous project and inside the package created new class Advanced Search and tried to run with Junit 4
it opens up the firefox with google.com and closes in few seconds with error
com.thoughtworks.selenium.SeleniumException: ERROR: Element num not found
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106)
at com.thoughtworks.selenium.DefaultSelenium.select(DefaultSelenium.java:345)
at com.selftechy.parameterization.AdvancedSearch.testAdvancedSearch(AdvancedSearch.java:20)
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:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Can you please help in resolving this?
Thanks in Advance
Ratikant
Selenium is not able to find the Element… can you post the code…
Hi,
Please find the code:
package com.selftechy.parameterization;
import com.thoughtworks.selenium.*;
import org.junit.*;
public class AdvancedSearch extends SeleneseTestBase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium(“localhost”, 4444, “*chrome”, “http://www.google.co.in/”);
selenium.start();
}
@Test
public void testAdvancedSearch() throws Exception {
selenium.open(“http://www.google.co.in/”);
selenium.click(“link=Advanced search”);
selenium.waitForPageToLoad(“30000”);
selenium.type(“as_q”, “selftechy, selenium, eclipse”);
selenium.select(“num”, “label=20 results”);
selenium.click(“//input[@value=’Advanced Search’]”);
selenium.waitForPageToLoad(“30000”);
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}
Instead of waitForPageToLoad, can you use Thread.sleep(2000) and see
Hi,
I have added the necessary jar files, but program is not executing rather it throws an exception in the output console saying
“Exception in thread “main” java.lang.Error: Unresolved compilation problems: webDriver cannot be resolved to a type
fireFoxDriver cannot be resolved to a type at fundamentals.MyFirstWeb.main(MyFirstWeb.java:9)”
The program is as shown below
package fundamentals;
import org.openqa.selenium.Webdriver;
import org.openqa.selenium.firefox.fireFoxDriver;
public class MyFirstWeb {
public static void main(String[] args) {
webDriver driver= new fireFoxDriver();
string url=”http://www.gmail.com”;
driver.get(url);
driver.close();
}
}
Looking forward to hear from you soon.
Thank you in advance……..
Hello,
I’m also new on Selenium trying it out. And I used your example and I get the same error as Ratikant. Did you guys get a solution to it?
I solved it by commenting or rather removing “//selenium.select(“num”, “label=20 results”);”
Hello, thanks a lot for this. I do have one question it is very confusing he he, I have a selenium RC test that runs in eclipse but I want to run it on Sauce labs through eclipse (Sauce labs is a cross browser testing program) I have Sauce labs set up in my eclipse eg. “driver.get(Site)”
(opens Site in Sauce labs browser). I want something like:
driver.start()
selenium.open(Site);
selenium.type(“id”, Name);
selenium.click(Submit);
driver.stop();
or
driver.selenium.open(Site)
driver.selenium.type(“id”, Name);
driver.selenium.click(Submit);
Is there any way to combine driver and selenium? I know that this is not possible but anything similar would be great. Sorry its so confusing but I am not very clever when it comes to programming 🙁
Thanks a bunch!
The error is shown at the lines
webDriver driver= new fireFoxDriver(); and for the above two import statements.
And yes I did try the “Thread.sleep(2000);” and got the same error.
Hi ,
Can some one help me to know why my selenese tests are not executed in the order i declare?
Thanks,
Hi seetaram ,
I’m from Manual Testing background and interested to work with Selenium. I have few question that my be basic questions.
1. Do we really need to have a knowledge of Java if we need to learn or work with Selenium.
2. Can we install Selenium on our personal laptop ( same machine can act as client and server ) ?
3. Can we export the test steps written in excel and run it in selenium ?
Desperately waiting for your reply.
Thanks
Arindam
Thanks,
Arindam,
1. Java knowledge is a must to work on Selenium (I mean any of the programming / scripting that Selenium supports)
2. Download Eclipse and configure the Selenium with your automation project
3. Record the test steps written in Excel in Selenium IDE and then export the code in JUnit / TestNG Java format and run in Eclipse
OR
Run directly in Selenium IDE
Warm Regards,
Seetaram
package pro1;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Junitprogramme {
@BeforeClass
public static void openapp ()
{
WebDriver wd = new FirefoxDriver();
wd.get(“http:cleartrip.com”);
}
}
when i was running this programm with the help of junit cleartrip browser is not cmng can u plss tell me how to do and can u plss forward to my mail id with total information because i was begginer for testing