Hi Ruchira,

Yes, the template is used to generate Java Source from recorded tests.
The template we attached have included contains ES specific configurations.
We have created a generic template (included below).

*Package name* will have to be configured accordingly in the *package *
section.

*@Test(groups = "", description = "") *will have to be completed as
required.

Following can be used according to the documentation similar to the
previous template.

*Sample Template for generic UI tests for TestNG*
--------------------------------------------------------------------------------------

package: com.example.tests

--------------------------------------------------------------------------

header:

--------------------------------------------------------------------------

package ${packageName};

import org.openqa.selenium.Alert;

import java.util.regex.Pattern;

import java.util.concurrent.TimeUnit;

import static org.testng.Assert.*;

import org.openqa.selenium.*;

import org.testng.annotations.AfterClass;

import org.testng.annotations.BeforeClass;

import org.testng.annotations.Test;

import org.openqa.selenium.support.ui.Select;

import org.wso2.carbon.automation.extensions.selenium.BrowserManager;


public class ${className} {

private WebDriver driver;

private String baseUrl;

private boolean acceptNextAlert = true;

  @BeforeClass(alwaysRun = true)

 public void setUp() throws Exception {

    driver = BrowserManager.getWebDriver();

       baseUrl = "${baseURL}";

       driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

 }

 @Test(groups = "", description = "")

 public void ${methodName}() throws Exception {

--------------------------------------------------------------------------

Footer:

--------------------------------------------------------------------------

 }

@AfterClass(alwaysRun = true)

public void tearDown() throws Exception {

    driver.quit();

}

private boolean isElementPresent(By by) {

    try {

        driver.findElement(by);

        return true;

    } catch (NoSuchElementException e) {

        return false;

    }

}

private boolean isAlertPresent() {

    try {

        driver.switchTo().alert();

        return true;

    } catch (NoAlertPresentException e) {

        return false;

    }

}

private String closeAlertAndGetItsText() {

    try {

        Alert alert = driver.switchTo().alert();

        String alertText = alert.getText();

        if (acceptNextAlert) {

            alert.accept();

        } else {

            alert.dismiss();

        }

        return alertText;

    } finally {

        acceptNextAlert = true;

    }

}

}

-----------------------------------------------------------------------------------------------------

On Thu, Oct 16, 2014 at 3:27 PM, Ruchira Wageesha <[email protected]> wrote:

>
>
> On Thu, Oct 16, 2014 at 2:38 PM, Ayesha Dissanayaka <[email protected]>
> wrote:
>
>> Hi all
>>
>> SameeraJ and I have been working on writing ui-integration test for
>> WSO2ES.
>>
>> For generating ui-test-cases we will use selenium IDE.
>>
>> In-order to auto generate test cases we can define a template using
>> Selenium IDE. We have come up with a sample template which we can reuse to
>> generate test-cases for ES apps.
>>
> AFAIK, this will generate the Java source(instead of writing it manually)
> for the selenium recoding that you do. Is this template specific to ES apps
> only or can others who want to write UI test cases use it?
>
>>
>> In [01]  we have explained how to use Selenium IDE with custom format to
>> generate test cases for ES Publisher UIs. Same way we can extend it for
>> other apps as well.
>>
>> [01]
>> https://docs.google.com/a/wso2.com/document/d/1FThVMLGIRQ6m-iyvOqZjdD1-nB6rA4iClPVeNN8Ba4c/edit?usp=sharing
>> or attachment "ES-UIIntegration.pdf"
>>
>> --
>> *Ayesha Dissanayaka*
>> Software Engineer,
>> WSO2, Inc : http://wso2.com
>> <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg>
>> 20, Palmgrove Avenue, Colombo 3
>> E-Mail: [email protected] <[email protected]>
>>
>
>
>
> --
>
> *Ruchira Wageesha**Associate Technical Lead*
> *WSO2 Inc. - lean . enterprise . middleware |  wso2.com <http://wso2.com>*
>
> *email: [email protected] <[email protected]>,   blog:
> ruchirawageesha.blogspot.com <http://ruchirawageesha.blogspot.com>,
> mobile: +94 77 5493444 <%2B94%2077%205493444>*
>



-- 



*Thanks & Regards,Sameera Jayaratna Software Engineer; **WSO2 Inc. *

*lean . enterprise . middleware |  http://wso2.com <http://wso2.com> *
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to