com.ppcxy.cyfm.showcase.functional.ajax.AjaxFT.java Source code

Java tutorial

Introduction

Here is the source code for com.ppcxy.cyfm.showcase.functional.ajax.AjaxFT.java

Source

/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.ppcxy.cyfm.showcase.functional.ajax;

import com.ppcxy.cyfm.showcase.functional.BaseSeleniumTestCase;
import org.junit.Test;
import org.openqa.selenium.By;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Ajax Mashup.
 *
 * @calvin
 */
public class AjaxFT extends BaseSeleniumTestCase {

    @Test
    public void mashup() {
        s.open("/");
        s.click(By.linkText("Web"));

        loginAsAdminIfNecessary();

        s.click(By.linkText("??Mashup"));

        s.click(By.xpath("//input[@value='?']"));
        s.waitForVisible(By.id("mashupContent"));
        assertThat(s.getText(By.id("mashupContent"))).isEqualTo("?");
    }

    private void loginAsAdminIfNecessary() {
        // ????
        if (s.getTitle().contains("")) {
            s.type(By.name("username"), "user");
            s.type(By.name("password"), "user");
            s.click(By.id("submit_btn"));
        }
    }
}