Forum Discussion
SmartBear_Suppo
Alumni
14 years agoHi,
It seems likely to me that the script is failing due to missing imports. It's likely that you will have to use the Grab annotation in Groovy to pull in the Selenium dependencies for this to work.
Another problem your script has is the private modifier, which isn't allowed for script level variables. I suggest simply removing these.
After applying both fixes, you should have something simmilar to this:
Regards,
Dain
SmartBear Software
It seems likely to me that the script is failing due to missing imports. It's likely that you will have to use the Grab annotation in Groovy to pull in the Selenium dependencies for this to work.
Another problem your script has is the private modifier, which isn't allowed for script level variables. I suggest simply removing these.
After applying both fixes, you should have something simmilar to this:
@Grab(group='org.seleniumhq.selenium', module='selenium-firefox-driver', version='2.9.0')
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Before;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;
FirefoxDriver driver;
String baseUrl = "http://www.somerandomsite.com";
driver = new FirefoxDriver();
driver.get(baseUrl);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.xpath("//a[@href=\"consultancy.html\"]")).click();
driver.findElement(By.xpath("//a[@href=\"aboutus.html\"]")).click();
driver.findElement(By.xpath("//a[@href=\"contactus.html\"]")).click();
driver.quit();
Regards,
Dain
SmartBear Software