I am using Webdriver + TestNG. I created a class where you can run any test with the browser of your choice just by using the method below where you enter which browser to run and what test to run as your variables. Now I am trying to feed my "browser" variable and "test" variable from a properties file. When I run it I just get a Pass but nothing happens. If I manually enter the variables it works fine. How come it wont take the values from the properties file? If I do a print - it prints the correct value...
This is the contents of the properties file:
browser="BROWSER GOES HERE"
test="TEST GOES HERE"
Here is my method to run the test:
#Test
public void runTest() throws IOException {
Properties prop = new Properties();
prop.load(new FileInputStream(
"path\\test.properties"));
localBrowser(prop.getProperty("browser"));
masterTest(driver, prop.getProperty("test"));
}
Here is a sandbox example of my test:
If I put the variables in myself the browser will open and execute the test. If I use the property loader it will just print the variables but will not run the test. Here is a sandbox example so you can try it.
Package Structure:
-src/test/java
--SandboxTest
-src/test/resources
--test.properties
Properties File example:
browser=firefox
test=test1
Class example:
public class SandboxTest {
private WebDriver driver;
InputStream input = null;
Properties prop = new Properties();
#Test
public void runTest() throws FileNotFoundException, IOException {
input = new FileInputStream(
(new File(
"C:INSERT_PATH_HERE\\test.properties")));
prop.load(input);
//This doesnt run the test
System.out.println(prop.getProperty("browser"));
System.out.println(prop.getProperty("test"));
localBrowser(prop.getProperty("browser"));
masterTest(driver, prop.getProperty("test"));
/*
* This works
* localBrowser("firefox");
* masterTest(driver, "test1");
*/
}
public void localBrowser(String browser) {
if (browser == "firefox") {
driver = new FirefoxDriver();
} else if (browser == "chrome") {
System.setProperty("webdriver.chrome.driver",
"C:\\INSERT_PATH_HERE\\chromedriver.exe");
driver = new ChromeDriver();
} else if (browser == "ie") {
System.setProperty("webdriver.ie.driver",
"C:\\INSERT_PATH_HERE\\IEDriverServer.exe");
driver = new InternetExplorerDriver(caps);
}
}
public void masterTest(WebDriver driver, String test) {
if (test == "test1") {
Test1(driver);
} else if (test == "test2") {
Test2(driver);
}
}
// *********************************TESTS*****************************************************
public void Test1(WebDriver driver) {
driver.get("http://www.marca.com/en/");
driver.findElement(By.linkText("Barcelona")).click();
}
public void Test2(WebDriver driver) {
driver.get("http://www.marca.com");
driver.findElement(By.linkText("Fútbol")).click();
}
}
Well.. I am really not sure what you are doing, But if it doesn't work so probably it doesn't load the properties file properly.
try this one
Resource resource = new ClassPathResource("/environment.properties");
properties = PropertiesLoaderUtils.loadProperties(resource);
Tell me if that is ok, hope that helps
EDIT:
The above is part of Spring,
you can use
prop.load(new FileInputStream(new File("test.properties")));
Please make sure that test.properties will be under src folder in the project
EDIT:
The problem not in the property file.. The problem is in the way you are comparing 2 strings
When you do browser == "firefox" The check is for the object address(referenec)
When you are comparing Object type you need to use Eqauls
For example browser.equals("firefox") It will work this way.
Because when you put the value your self it check the refernece and it is the same.. Once you get from property this is 2 diffrent objects but they are "equal" So it will work only with Equals
What you should do instead is put the property in the testing.xml file and then read the property from there instead. Then, if you need to have different property files, you can just create multiple testing.xml files and when you execute the tests just pass the testng.xml file as an argument to TestNG.
In the project I referenced above in the hyperlink, you can see I reference the properties something like so:
#BeforeClass
public void setUp( ITestContext context ) {
suiteParams = context.getSuite().getXmlSuite().getAllParameters();
String browser = suiteParams.get( "browser" );
String sauceUser = suiteParams.get( "sauceUser" );
String sauceKey = suiteParams.get( "sauceKey" )
....
If you have to do it using a properties file, then I would change you code and do it differently. Something like so (assuming use of TestNG):
protected WebDriver driver;
protected String browser;
#BeforeTest
public void setUp() {
Properties prop = new Properties();
prop.load( new FileInputStream("path/test.properties") );
browser = prop.getProperty("browser");
if ( browser.equals("firefox") {
driver = new FirefoxDriver();
} else {
driver = null; // bad choice
}
}
#Test
public void runTest() throws IOException {
driver.navigateTo( url);
// do stuff
Assert.assertTrue( 1 == 1 );
}
#AfterTest
public void cleanUp() {
driver.quit();
}
Related
I am trying to run different classes parallarly though testNG to generate one single extent report for all classes. Also I am trying to generate logs for each classes which will be shown in the extent report. However when the extent report is generated I can see that the logs for a test case of one class is shown in the test case of other class. How to resolve this issue? Below is my code:
//// This is my base class for extent report:
#BeforeSuite
public static void setUp()
{
htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir") +"/test-output/MyOwnReport.html");
report = new ExtentReports();
report.attachReporter(htmlReporter);
report.setSystemInfo("OS", "Mac Sierra");
report.setSystemInfo("Host Name", "Testing Xpert");
report.setSystemInfo("Environment", "QA");
report.setSystemInfo("User Name", "Vivek");
htmlReporter.config().setChartVisibilityOnOpen(true);
htmlReporter.config().setDocumentTitle("AutomationTesting.in Demo Report");
htmlReporter.config().setReportName("My Own Report");
htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
htmlReporter.config().setTheme(Theme.DARK);
}
//Creating a method getScreenshot and passing two parameters
//driver and screenshotName
public static String getScreenshot(WebDriver driver, String screenshotName) throws Exception {
//below line is just to append the date format with the screenshot name to avoid duplicate names
String dateName = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
TakesScreenshot ts = (TakesScreenshot) driver;
File source = ts.getScreenshotAs(OutputType.FILE);
String destination = System.getProperty("user.dir") + "/test-output/"+screenshotName+dateName+".png";
File finalDestination = new File(destination);
FileHandler.copy(source, finalDestination);
//FileUtils.copyFile(source, finalDestination);
return destination;
}
#AfterMethod
public void getResult(ITestResult result) throws Exception
{
if(result.getStatus() == ITestResult.FAILURE)
{
test.log(Status.FAIL, "Test Case Failed is "+result.getName());
// test.log(Status.FAIL, "Test Case Failed is "+result.getThrowable());
String screenshotPath = ExtentReportBaseClass.getScreenshot(UtilityMethods.getdriver(), result.getName());
test.log(Status.FAIL, (Markup) test.addScreenCaptureFromPath(screenshotPath));
//test.log(Status.FAIL, MarkupHelper.createLabel(result.getName()+" Test case FAILED due to below issues:",test.addScreenCaptureFromPath(screenshotPath)));
test.fail(result.getThrowable());
}
else if(result.getStatus() == ITestResult.SUCCESS)
{
test.log(Status.PASS, "Test Case Passed is "+result.getName());
}
else
{
test.log(Status.SKIP, MarkupHelper.createLabel(result.getName()+" Test Case SKIPPED", ExtentColor.ORANGE));
test.skip(result.getThrowable());
}
}
#AfterSuite
public void tearDown()
{
report.flush();
}
There are my two classes which i am running. Method for generating logs are defined in the class.(test.log(test.getStatus(), "This will add item to the cart");)
public class PurchaseItemTestCase extends ExtentReportBaseClass{
#BeforeClass
public void launchBrowser() throws InterruptedException {
//System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
//driver = new ChromeDriver();
driver = util.openBrowser(ConstantsValues.BROWSER_NAME);
util.launchWebsite();
driver.manage().window().maximize();
//report = ExtentReportBaseClass.setUp();
}
#Test
public void chkPurchaseItem() throws InterruptedException {
//ExtentTest test;
test = report.createTest("chkPurchaseItem", "This will check status for purchasing an item.");
driver.findElement(By.xpath("//img[#title='Faded Short Sleeve T-shirts']")).click();
driver.switchTo().defaultContent();
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[contains(#id,'fancy')]")));
System.out.println("after frame");
Thread.sleep(4000);
test.log(test.getStatus(), "This will add item to the cart");
driver.findElement(By.xpath("//button[#type='submit']//span[contains(.,'Add')]")).click();
Set handles = driver.getWindowHandles();
System.out.println(handles);
// Pass a window handle to the other window
for (String handle1 : driver.getWindowHandles()) {
System.out.println(handle1);
driver.switchTo().window(handle1);
Thread.sleep(3000);
driver.findElement(By.xpath("//a[#title='Proceed to checkout']//span[contains(.,'Proceed')]")).click();
Thread.sleep(3000);
driver.findElement(By.xpath(
"//a[#class='button btn btn-default standard-checkout button-medium']//span[contains(.,'Proceed')]//i[#class='icon-chevron-right right']"))
.click();
test.log(test.getStatus(), "We will login to the account");
driver.findElement(By.id("email")).sendKeys("vivekkumar009#gmail.com");
driver.findElement(By.id("passwd")).sendKeys("vivek123");
Thread.sleep(3000);
// UtilityMethods.getdriver().findElement(By.id("SubmitLogin"));
driver.findElement(By.id("SubmitLogin")).click();
test.log(test.getStatus(), "User will add address for shipment");
driver.findElement(By.name("processAddress")).click();
test.log(test.getStatus(), "User will agree to terms and condition ");
driver.findElement(By.id("cgv")).click();
driver.findElement(By.xpath("//button[#name=\"processCarrier\"]")).click();
driver.findElement(By.className("cheque")).click();
test.log(test.getStatus(), "User confirms order");
driver.findElement(By.xpath("//span[contains(text(),'I confirm my order')]")).click();
boolean chkElement = util.getdriver().findElement(By.className("home")).isDisplayed();
System.out.println(chkElement);
Assert.assertTrue(chkElement);
}
this is the 2nd class:
public class CategoryWisePurchase extends ExtentReportBaseClass {
#BeforeClass
public void launchApplicationBrowser() {
util.openBrowser(ConstantsValues.BROWSER_NAME);
util.launchWebsite();
}
#Test
public void CategoryWiseShopping() throws InterruptedException {
test = report.createTest("Category Wise Shopping", "This will check if the user is able to shop different products by selecting its category");
// Actions actions = new Actions(UtilityMethods.getdriver());
Actions action = new Actions(UtilityMethods.getdriver());
test.log(test.getStatus(), "User will select the category of a particular item");
WebElement mainMenu = UtilityMethods.getdriver().findElement(By.xpath("//a[#title='Women']"));
WebElement subMenu = UtilityMethods.getdriver().findElement(By.xpath("//a[#title='T-shirts']"));
action.moveToElement(mainMenu).build().perform();
Thread.sleep(2000);
action.moveToElement(subMenu).click().build().perform();
test.log(test.getStatus(), "Various products will be shown to the user of the selected category");
//reportLog("Various products will be shown to the user of the selected category");
boolean chkElement = UtilityMethods.getdriver().findElement(By.xpath("//form[#method='post']")).isDisplayed();
System.out.println(chkElement);
Assert.assertTrue(chkElement);
}
}
That will happen if the test is in your Base class. In parallel, the test will be used by all classes that inherit your Base class. Better to use a threadlocal here or an implementation similar to:
https://github.com/anshooarora/extentreports-java/blob/master/src/test/java/com/aventstack/extentreports/common/ExtentTestManager.java
Also, is you see the examples section of the docs, you already have a barebones ExtentTestNGReportBuilder example which you can use without creating any custom code like here.
I am attempting to test a method that returns a File object using JUnit and JMockit. I am a beginner with both of these.
The problem I am having is that I can't figure out how to properly/successfully mock the implementation method returning a file, since in reality, the user has to actually select a file for the method to return. The error I keep running into is:
java.lang.IllegalStateException: Missing invocation to mocked type at this point; please make sure such invocations appear only after the declaration of a suitable mock field or parameter
Any suggestions?
Here is a recreation of my implementation:
public final class MyClass {
public static File OpenFile(Stage stage, String title, String fileTypeText, ArrayList<String> fileType) throws Exception {
File file = null;
try {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(title);
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionsFilter(fileTypeText + fileType, fileType);
fileChooser.getExtensionsFilters().add(extFilter);
file = fileChooser.showOpenDialog(stage);
return file;
}
catc (Exception e) {
if(fileType==null) {
...
}
return file;
}
}
}
Here is a recreation of my attempted JUnit test:
#Test
public void TestOpenFile(#Mocked Stage stage) throws Exception {
final ArrayList<String> extensions = new ArrayList<String>();
extensions.add(".txt");
final File file = null;
new Expectations() {{
MyClass.OpenFile(stage, anyString, anyString, extensions); returns(file);
}};
assertEquals(file, MyClass.OpenFile(stage, "some title", "some type", extensions));
}
Your solution is correct, but I would use expectations instead:
public void TestOpenFile(#Mocked FileChooser chooser) throws Exception{
new Expectations() {
{
chooser.showOpenDialog(stage); result = expectedFile;
}};
final File actualFile = MyClass.OpenFile(...);
assertEquals(expectedFile, actualFile);}
I find this easier to understand and write (my personal preference)
I realized that I was approaching the problem incorrectly at first. What I did to resolve this was:
Mock the FileChooser.showOpenDialog method to return a file instead of trying to mock my own method to return a file, which would have defeated the purpose of testing.
final File expectedFile = new File("abc");
new MockUp<FileChooser>() {
#Mock
File showOpenDialog(final Window overWindow) {
return expectedFile;
}
};
final File actualFile = MyClass.OpenFile(...);
assertEquals(expectedFile, actualFile);
Hi I am working on a project and using PrintWriter class for opening and writing in the file. But when I am writing the test case for same it gives following error at Line 153
Wanted but not invoked:
mockPrintWriter.println("ID url1
");
-> at x.y.z.verify(ProcessImageDataTest.java:153)
Actually, there were zero interactions with this mock.
Code: (Uses Lombok Library)
ProcessImageData.java
#Setter
#RequiredArgsConstructor
public class ProcessImageData implements T {
private final File newImageDataTextFile;
#Override
public void execute() {
LineIterator inputFileIterator = null;
try {
File filteredImageDataTextFile = new File(filteredImageDataTextFilepath);
PrintWriter writer = new PrintWriter(newImageDataTextFile);
inputFileIterator = FileUtils.lineIterator(filteredImageDataTextFile, StandardCharsets.UTF_8.displayName());
while (inputFileIterator.hasNext()) {
if(someCondition)
**Line51** writer.println(imageDataFileLine);
//FileUtils.writeStringToFile(newImageDataTextFile, imageDataFileLine + NEWLINE, true);
}
}
} catch (Exception e) {
} finally {
LineIterator.closeQuietly(inputFileIterator);
**LINE63** writer.close();
}
}
ProcessImageDataTest.java
#RunWith(PowerMockRunner.class)
#PrepareForTest({ ProcessImageData.class, FileUtils.class, Printwriter.class })
public class ProcessImageDataTest {
private ProcessImageData processImageData;
private static final String FILTERED_IMAGE_DATA_TEXT_FILE_PATH = "filteredFilepath";
private File FILTEREDFILE = new File(FILTERED_PATH);
private static final File IMAGE__FILE = new File("imageFilePath");
private LineIterator lineIterator;
#Mock
private PrintWriter mockPrintWriter;
#Before
public void init() throws Exception {
MockitoAnnotations.initMocks(this);
processImageData = new ProcessImageData(Palettes_file, FILTERED_PATH, IMAGE_FILE);
PowerMockito.mockStatic(FileUtils.class);
PowerMockito.whenNew(PrintWriter.class).withArguments(IMAGE_FILE).thenReturn(mockPrintWriter);
PowerMockito.when(FileUtils.lineIterator(FILTERED_FILE, StandardCharsets.UTF_8.displayName())).thenReturn(lineIterator);
PowerMockito.when(lineIterator.hasNext()).thenReturn(true, true, false);
}
#Test
public void testTaskWhenIDInDBAndStale() throws IOException {
PowerMockito.when(lineIterator.nextLine()).thenReturn(ID2 + SPACE + URL1, ID1 + SPACE + URL2);
processImageData.execute();
List<String> exepctedFileContentOutput = Arrays.asList(ID2 + SPACE + URL1 + NEWLINE);
verify(exepctedFileContentOutput, 1, 1);
}
#Test
public void testTaskWhenIDNotInDB() throws IOException {
PowerMockito.when(lineIterator.nextLine()).thenReturn(ID2 + SPACE + URL1, ID3 + SPACE + URL2);
processImageData.execute();
List<String> exepctedFileContentOutput = Arrays.asList(ID3 + SPACE + URL2 + NEWLINE);
verify(exepctedFileContentOutput, 1, 1);
}
private void verify(List<String> exepctedFileContentOutput, int fileWriteTimes, int fileReadTimes) throws IOException {
for (String line : exepctedFileContentOutput){
**Line153** Mockito.verify(mockPrintWriter, Mockito.times(fileWriteTimes)).print(line);
}
PowerMockito.verifyStatic(Mockito.times(fileReadTimes));
FileUtils.lineIterator(FILTERED_IMAGE_DATA_TEXT_FILE, StandardCharsets.UTF_8.displayName());
}
}
I am mocking a new operator for PrintWriter also, injecting using beans. What is the mistake I am doing?? I am stuck on it from long time and not getting the error?
Any help is appreciated.
Updated :
I did changes suggested below and updated the code, but now I get the error:
Wanted but not invoked: mockPrintWriter.print("ASIN2 url1 "); ->
at softlines.ctl.ruleExecutor.tasks.ProcessImageDataTest.verify(ProcessImageDataTest.java:153)
However, there were other interactions with this mock: -> at softlines.ctl.ruleExecutor.tasks.ProcessImageData.execute(ProcessImageData.java:51) ->
at softlines.ctl.ruleExecutor.tasks.ProcessImageData.execute(ProcessImageData.java:51) ->
at softlines.ctl.ruleExecutor.tasks.ProcessImageData.execute(ProcessImageData.java:58) –
I see 3 issues in your test:
You don't try to mock the correct constructor, indeed in the method execute, you create your PrintWriter with only one argument of type File while you try to mock the constructor with 2 arguments one of type File and the other one of type String.
So the code should rather be:
PowerMockito.whenNew(PrintWriter.class)
.withArguments(IMAGE_FILE)
.thenReturn(mockPrintWriter);
To be able to mock a constructor you need to prepare the class creating the instance which is ProcessImageData in this case, so you need to add ProcessImageData.class in the annotation #PrepareForTest. (I'm not sure ProcessImageDataTest.class is needed there)
The field lineIterator should be annotated with #Mock.
Instead of verifying print with a new line, you should verify directly println without new line it is much less error prone.
I simplified your code to show the idea.
Assuming that ProcessImageData is:
public class ProcessImageData {
private final File newImageDataTextFile;
public ProcessImageData(final File newImageDataTextFile) {
this.newImageDataTextFile = newImageDataTextFile;
}
public void execute() throws Exception{
try (PrintWriter writer = new PrintWriter(newImageDataTextFile)) {
LineIterator inputFileIterator = FileUtils.lineIterator(
newImageDataTextFile, StandardCharsets.UTF_8.displayName()
);
while (inputFileIterator.hasNext()) {
writer.println(inputFileIterator.nextLine());
}
}
}
}
My unit test would then be:
#RunWith(PowerMockRunner.class)
#PrepareForTest({ProcessImageData.class, FileUtils.class})
public class ProcessImageDataTest {
private File file = new File("imageFilePath");
private ProcessImageData processImageData;
#Mock
private PrintWriter mockPrintWriter;
#Mock
private LineIterator lineIterator;
#Before
public void init() throws Exception {
MockitoAnnotations.initMocks(this);
processImageData = new ProcessImageData(file);
PowerMockito.whenNew(PrintWriter.class)
.withArguments(file)
.thenReturn(mockPrintWriter);
PowerMockito.mockStatic(FileUtils.class);
PowerMockito.when(
FileUtils.lineIterator(file, StandardCharsets.UTF_8.displayName())
).thenReturn(lineIterator);
PowerMockito.when(lineIterator.hasNext()).thenReturn(true, true, false);
}
#Test
public void testExecute() throws Exception {
PowerMockito.when(lineIterator.nextLine()).thenReturn("Foo", "Bar");
processImageData.execute();
Mockito.verify(mockPrintWriter, Mockito.times(1)).println("Foo");
Mockito.verify(mockPrintWriter, Mockito.times(1)).println("Bar");
}
}
For more details please refer to How to mock construction of new objects.
how can I add verification in unit test for writer.close?
One way could be to simply check that close() at be called once by adding the next line to your unit test:
Mockito.verify(mockPrintWriter, Mockito.times(1)).close();
Your construction of the PrintWriter doesn't match the mock. You told PowerMockito to return your mock like this:
PowerMockito.whenNew(PrintWriter.class).withArguments(IMAGE_FILE , StandardCharsets.UTF_8.name()).thenReturn(mockPrintWriter);
So you would have to say:
new PrintWriter(IMAGE_FILE, "UTF-8"); // 2 arguments
But instead in your execute method in the code that is being tested, you do:
PrintWriter writer = new PrintWriter(newImageDataTextFile); // only 1 argument
So you either need to change the PowerMockito withArguments clause, or you need to add "UTF-8" to the constructor invocation in the execute method.
I am searching for an element in selenium webdriver, via an object file. All other elements are getting returned, apart from one. I have tried configuring the locator to xpath, cssselector and name etc.
When I try to locate the element directly from the console by id or any other locator, it is located successfully. Just not via the object file.
All information is correct in the object file and in console
Here is object file content:
one=.//*[#id='1']
two=.//*[#id='2']
three=.//*[#id='3']
four=.//*[#id='4']
five=.//*[#id='5']
six=.//*[#id='6']
seven=.//*[#id='7']
eight=.//*[#id='8']
nine=.//*[#id='9']
zero=.//*[#id='0']
equalsto=.//*[#id='equals']
cler=.//*[#id='AC']
result=.//*[#id='Resultbox']
plus=.//*[#id='plus']
minus=.//*[#id='minus']
mul=.//*[#id='multiply']
heading=.//*[#id='Blog1']/div[1]/div/div/div/div[1]/h3
Here is code:
public class CalcTest {
WebDriver driver = new FirefoxDriver();
#BeforeMethod
public void openbrowser() throws IOException, InterruptedException {
driver.manage().window().maximize();
driver.get("http://only-testing-blog.blogspot.in/2014/04/calc.html");
}
/*#AfterMethod
public void closebrowser() {
driver.quit();
}*/
#Test
public void Calc_Operations() throws IOException, InterruptedException {
// Create Object of Properties Class.
Properties obj = new Properties();
// Create Object of FileInputStream Class. Pass file path.
FileInputStream objfile = new FileInputStream(
System.getProperty("user.dir") + "\\src\\Objects\\objects.properties");
// Pass object reference objfile to load method of Properties object.
obj.load(objfile);
// Sum operation on calculator.
// Accessing element locators of all web elements using
// obj.getProperty(key)
String heading = driver.findElement(By.xpath(obj.getProperty("heading"))).getText();
System.out.println(heading);
driver.findElement(By.xpath(obj.getProperty("eight"))).click();
driver.findElement(By.xpath(obj.getProperty("plus"))).click();
driver.findElement(By.xpath(obj.getProperty("four"))).click();
driver.findElement(By.xpath(obj.getProperty("equalsto"))).click();
Thread.sleep(4000);
driver.findElement(By.xpath(("result"))).getAttribute("value");
//String i = driver.findElement(By.name(obj.getProperty("result"))).getAttribute("value");
//System.out.println(i);
//System.out.println(obj.getProperty("eight") + " + " + obj.getProperty("four") + " = " + i);
driver.findElement(By.xpath(obj.getProperty("result"))).clear();
I want to test a smart GWT app using Selenium.
For this I need to add up
1. user-extensions.js
2. user-extensions-ide.js
in the IDE.
This gives an additional scLocators for locating GWT elements on the page
Now if I want to test the above page using Java, then where will I add these js files in the code
The way I approached this was using the SeleniumServer method, which allowed me to specify my extension file from the java code.
A working SmartGWT example is:
public class Example {
SeleniumServer server = null;
Selenium selenium = null;
HttpCommandProcessor proc = null;
#Before
public void setUp() throws Exception {
RemoteControlConfiguration config = new RemoteControlConfiguration();
config.setUserExtensions(new File("bin/selenium/user-extensions.js"));
server = new SeleniumServer(config);
server.boot();
proc = new HttpCommandProcessor("localhost",
4444,
"*firefox",
"http://test");
selenium = new DefaultSelenium(
proc);
selenium.start();
selenium.open("http://test");
}
#Test
public String justATest() {
execCommand("waitForElementClickable", "scLocator=//Window[ID=\"errorWindow\"]/item[0][Class=\"Label\"]/");
String elementTest = selenium.getText("scLocator=//Window[ID=\"errorWindow\"]/item[0][Class=\"Label\"]/");
assertEquals(elementTest, "lorem");
}
protected String execCommand(String command, String locator) {
String[] locatorArg = {locator};
return proc.doCommand(command, locatorArg);
}
#After
public void stopSelenium() {
System.out.println("in after hook");
if (selenium != null) {
selenium.deleteAllVisibleCookies();
selenium.stop();
}
if (server != null) {
server.stop();
}
System.out.println("after after hook");
}
}