I have selenium TestNG test written in java and using STS IDE. I use testNG.xml file to run it as testNG Suite. I use Bitbucket to store all the repositories. Now I want to run the Selenium TestNG test using Bamboo. I have already connected Bamboo to Bitbucket to use the repositories. But I can't figure out how to configure the testNG.xml file, java file, and the jar to Bamboo.
Does any one have any ideas of how to go about it. I have searched from the net for quite sometime, but I haven't come across any good tutorial or guide of how to go about it.
Here are the files I was using in STS IDE:
JARS
- selenium-java-2.44.0.jar
- selenium-java-2.44.0-srcs.jar
CONFIG.PROPERTIES FILE
url=http://mnn.com/
XML FILE
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="JobGo Suite">
<test name="FirefoxTest">
<parameter name="browser" value="firefox" />
<classes>
<class name="com.mnn.MeTab"/>
</classes>
</test>
</suite>
JAVA FILE
package com.mnn;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class MeTab{
private WebDriver driver;
private String propertyFileName = "config.properties";
private InputStream inputStream = MeTab.class.getClassLoader().getResourceAsStream(propertyFileName);
private Properties prop = new Properties();
/*
* Opens the browser and navigate to the Landing Page
*/
@BeforeClass
@Parameters("browser")
public void beforeTest(String browser) throws IOException{
if(browser.equalsIgnoreCase("firefox")){
driver = new FirefoxDriver();
}else if(browser.equalsIgnoreCase("chrome")){
driver = new ChromeDriver();
}else if(browser.equalsIgnoreCase("ie")){
driver = new InternetExplorerDriver();
}else{
throw new RuntimeException("Browser type unsupported");
}
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
prop.load(inputStream);
if( inputStream == null ){
throw new FileNotFoundException("property file " + propertyFileName +
" not found in the classpath");
}
// navigate to jobgo web site
driver.get(prop.getProperty("url"));
// Maximize the browser Window
driver.manage().window().maximize();
} // end of method beforeTest
/*
* Method tests the landing page
*
*/
@Test(priority = 0)
public void testLogin() throws Exception{
//time that elapses as the browser as the browser waits before executing
WebDriverWait wait = new WebDriverWait(driver, 120);
// Text has to be visible before another process is executed
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("login")));
// Click on Login
WebElement muwl = driver.findElement(By.className("Model_User_Widget_Login"));
muwl.findElement(By.className("login")).click();
// From the Login pop up, use the Sign In tab to login known credentials to the application
WebElement username = driver.findElement(By.className("login_form"));
username.findElement(By.id("main_username")).clear();
username.findElement(By.id("main_username")).sendKeys("mnn@yahoo.com");
// From the Login pop up, use the Sign In tab to login known credentials to the application
WebElement passwd = driver.findElement(By.className("login_form"));
passwd.findElement(By.id("main_password")).clear();
passwd.findElement(By.id("main_password")).sendKeys("123kdd12");
// Check if 'Remember me' checkbox is not checked then check it
WebElement notChkbox = driver.findElement(By.className("chkbox"));
if(!notChkbox.isSelected()){
notChkbox.click();
}
Thread.sleep(3000);
// If 'Remember me' checkbox is checked then uncheck it
WebElement chkbox = driver.findElement(By.className("chkbox"));
if(chkbox.isSelected()){
chkbox.click();
}
Thread.sleep(3000);
// Click on 'Sign in' button
WebElement signIn = driver.findElement(By.className("login_form"));
signIn.findElement(By.className("login_btn")).click();
// Text has to be visible before another process is executed
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("well_txt")));
}
/*
* Closes the browser
*/
@AfterClass
public void quitDriver() throws Exception{
Thread.sleep(3000);
driver.quit();
} // end of method quitDriver
}
Please any help is welcome.
Cheers, Nelson