Selenium
A sample java-selenuim code to upload an artifact (Helloword.aar) on your desktop to wso2 application server instance. Note that we will use firefox browser for the demonstration.
package selenium;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import static org.testng.Assert.assertEquals;
public class AppserverArtifactUpload {
private static final Log log = LogFactory.getLog(AppserverArtifactUpload.class);
public static void main(String[] args) {
// Initializing the web driver
WebDriver driver = new FirefoxDriver();
// Setting the url
driver.get("https://ip:port/carbon/");
// your server ip & port (eg: ip-100.100.100.100 , port- 9443)
// Creating username & password fields
WebElement userName = driver.findElement(By.name(("username")));
WebElement password = driver.findElement(By.name(("password")));
// Setting values for username & password
userName.sendKeys("admin");
password.sendKeys("admin");
// Now submit the form. WebDriver
password.submit();
// Check the title of the page
log.info("Page Title : " + driver.getTitle());
assertEquals("WSO2 Management Console", driver.getTitle(), "Page Title Mismatch");
// Traveling to AAR upload page
driver.findElement(By.xpath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr/td/div/ul/li[5]/ul/li[4]/ul/li[3]/ul/li/a")).click();
/*// if u want to add additional browser buttons
driver.findElement(By.cssSelector("input[type='button']")).click();*/
// browsing and selecting the .aar file
driver.findElement(By.xpath("/html/body/table/tbody/tr[2]/td[3]/table/tbody" +
"/tr[2]/td/div/div/form/table/tbody/tr[2]/td/input"))
.sendKeys("/home/dimuthu/Desktop/HelloWorld.aar");
// uploading the selected aar file
WebElement upload = driver.findElement(By.name(("upload")));
upload.submit();
log.info("HelloWorld.aar uploaded successfully");
}
}