Thursday, November 28, 2013


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
        // your server ip & port (eg: ip- , port- 9443)

        // Creating username & password fields
        WebElement userName = driver.findElement("username")));
        WebElement password = driver.findElement("password")));

        // Setting values for username & password

        // Now submit the form. WebDriver

        // Check the title of the page"Page Title : " + driver.getTitle());
        assertEquals("WSO2 Management Console", driver.getTitle(), "Page Title Mismatch");

        // Traveling to AAR upload page

        /*// if u want to add additional browser buttons

        // browsing and selecting the .aar file
        driver.findElement(By.xpath("/html/body/table/tbody/tr[2]/td[3]/table/tbody" +

        // uploading the selected aar file
        WebElement upload = driver.findElement("upload")));
        upload.submit();"HelloWorld.aar uploaded successfully");

No comments:

Post a Comment