Search in sources :

Example 1 with InternalBrowser

use of org.eclipse.reddeer.swt.impl.browser.InternalBrowser in project jbosstools-openshift by jbosstools.

the class ConnectionWizardHandlingTest method testLinkToRetrieveToken.

@Test
@Ignore("Link has been changed to Styled text. Test need to be corrected")
public void testLinkToRetrieveToken() {
    new LabeledCombo(OpenShiftLabel.TextLabels.SERVER_TYPE).setSelection(OpenShiftLabel.Others.OPENSHIFT3);
    new LabeledCombo(OpenShiftLabel.TextLabels.PROTOCOL).setSelection(AuthenticationMethod.OAUTH.toString());
    try {
        new DefaultStyledText("Enter a token or retrieve a new one.");
    // pass
    } catch (RedDeerException ex) {
        fail("Link to retrieve token for a connection is not available.");
    }
    new LabeledCombo(OpenShiftLabel.TextLabels.SERVER).setText("https://nonexisting.server.com");
    WidgetHandler.getInstance().sendClickNotifications(new DefaultStyledText("Enter a token or retrieve a new one.").getSWTWidget());
    // There can be problem occured dialog, or it is only in log
    try {
        new DefaultShell("Problem Occurred");
        new OkButton().click();
        new WaitWhile(new ShellIsAvailable("Problem Occurred"));
        new DefaultShell("");
    // pass
    } catch (RedDeerException ex) {
    // pass
    }
    try {
        new InternalBrowser();
        fail("Browser with token should not opened for nonexisting server.");
    } catch (RedDeerException ex) {
    // pass
    }
    new LabeledCombo(OpenShiftLabel.TextLabels.SERVER).setText(DatastoreOS3.SERVER);
    WidgetHandler.getInstance().sendClickNotifications(new DefaultStyledText("Enter a token or retrieve a new one.").getSWTWidget());
    try {
        new ShellWithButton("", "Close");
        new PushButton("Close").click();
        AbstractWait.sleep(TimePeriod.SHORT);
    } catch (RedDeerException ex) {
        fail("Browser with token was not opened.");
    }
}
Also used : OkButton(org.eclipse.reddeer.swt.impl.button.OkButton) ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) RedDeerException(org.eclipse.reddeer.common.exception.RedDeerException) ShellWithButton(org.jboss.tools.openshift.reddeer.widget.ShellWithButton) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) LabeledCombo(org.eclipse.reddeer.swt.impl.combo.LabeledCombo) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) InternalBrowser(org.eclipse.reddeer.swt.impl.browser.InternalBrowser) DefaultStyledText(org.eclipse.reddeer.swt.impl.styledtext.DefaultStyledText) PushButton(org.eclipse.reddeer.swt.impl.button.PushButton) Ignore(org.junit.Ignore) AbstractTest(org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest) Test(org.junit.Test)

Example 2 with InternalBrowser

use of org.eclipse.reddeer.swt.impl.browser.InternalBrowser in project jbosstools-openshift by jbosstools.

the class BrowserContainsText method test.

@Override
public boolean test() {
    browser = new InternalBrowser();
    if (url != null) {
        browser.setURL(url);
        if (refresh)
            browser.refresh();
    } else {
        if (refresh)
            browser.refresh();
    }
    new WaitUntil(new PageIsLoaded(browser));
    if (Platform.getOS().startsWith(Platform.OS_WIN32)) {
        return browser.getText().contains(text);
    } else {
        // Workaround for webkit issues with method browser.getText(), e.g. https://bugs.eclipse.org/bugs/show_bug.cgi?id=514719
        String pageHTML = "";
        if (!StringUtils.isEmptyOrNull(browser.getURL())) {
            pageHTML = (String) browser.evaluate("return document.documentElement.innerHTML;");
        }
        return pageHTML.contains(text);
    }
}
Also used : InternalBrowser(org.eclipse.reddeer.swt.impl.browser.InternalBrowser) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil)

Example 3 with InternalBrowser

use of org.eclipse.reddeer.swt.impl.browser.InternalBrowser in project jbosstools-openshift by jbosstools.

the class AuthenticationTokenRetrival method retrieveToken.

/**
 * Represents action of clicking on retrieve new token link, wait for browser to
 * appear, log in and obtain new token.
 *
 * @return token string
 */
public String retrieveToken() {
    EmulatedLinkStyledText linkText = new EmulatedLinkStyledText(OpenShiftLabel.TextLabels.RETRIEVE_TOKEN);
    linkText.click(linkText.getPositionOfText(OpenShiftLabel.TextLabels.LINK_RETRIEVE) + 3);
    new WaitUntil(new ShellIsActive(new WithTextMatcher("Unnamed")), TimePeriod.MEDIUM, false);
    DefaultShell browser = new DefaultShell();
    InternalBrowser internalBrowser = new InternalBrowser(browser);
    login(internalBrowser);
    new WaitUntil(new LoginPageIsLoaded(() -> internalBrowser.getText().contains(PAGETITLE_API_TOKEN)));
    String token = getTokenFromBrowser(internalBrowser);
    // close browser shell
    new PushButton(OpenShiftLabel.Button.CLOSE).click();
    return token;
}
Also used : ShellIsActive(org.eclipse.reddeer.swt.condition.ShellIsActive) WithTextMatcher(org.eclipse.reddeer.core.matcher.WithTextMatcher) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) InternalBrowser(org.eclipse.reddeer.swt.impl.browser.InternalBrowser) LoginPageIsLoaded(org.jboss.tools.openshift.reddeer.condition.LoginPageIsLoaded) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) PushButton(org.eclipse.reddeer.swt.impl.button.PushButton)

Example 4 with InternalBrowser

use of org.eclipse.reddeer.swt.impl.browser.InternalBrowser in project jbosstools-openshift by jbosstools.

the class OpenNewApplicationWizardWithNoProjectTest method testOpenNewApplicationWizardFromCentralWithNoProjects.

@Test
public void testOpenNewApplicationWizardFromCentralWithNoProjects() {
    new DefaultToolItem(new WorkbenchShell(), OpenShiftLabel.Others.RED_HAT_CENTRAL).click();
    new InternalBrowser().execute(OpenShiftLabel.Others.OPENSHIFT_CENTRAL_SCRIPT);
    new WaitUntil(new ShellIsAvailable(OpenShiftLabel.Shell.NEW_APP_WIZARD), TimePeriod.LONG);
    new DefaultShell(OpenShiftLabel.Shell.NEW_APP_WIZARD);
    for (String comboItem : new DefaultCombo(0).getItems()) {
        if (comboItem.contains(connectionReq.getUsername()) && comboItem.contains(connectionReq.getHost())) {
            new DefaultCombo(0).setSelection(comboItem);
            break;
        }
    }
    new NextButton().click();
    new WaitUntil(new ShellIsAvailable(OpenShiftLabel.Shell.CREATE_OS_PROJECT), TimePeriod.LONG);
    new DefaultShell(OpenShiftLabel.Shell.CREATE_OS_PROJECT);
    new LabeledText(OpenShiftLabel.TextLabels.PROJECT_NAME).setText(projectName);
    new FinishButton().click();
    new WaitWhile(new ShellIsAvailable(OpenShiftLabel.Shell.CREATE_OS_PROJECT), TimePeriod.LONG);
    new WaitWhile(new JobIsRunning(), TimePeriod.LONG);
    new WaitUntil(new ControlIsEnabled(new BackButton()), TimePeriod.LONG);
    new DefaultShell(OpenShiftLabel.Shell.NEW_APP_WIZARD);
    assertTrue("Created project was not preselected for a new OpenShift application", new LabeledCombo(OpenShiftLabel.TextLabels.PROJECT).getText().equals(projectName));
    closeWizard();
}
Also used : ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) NextButton(org.eclipse.reddeer.swt.impl.button.NextButton) LabeledCombo(org.eclipse.reddeer.swt.impl.combo.LabeledCombo) LabeledText(org.eclipse.reddeer.swt.impl.text.LabeledText) DefaultToolItem(org.eclipse.reddeer.swt.impl.toolbar.DefaultToolItem) BackButton(org.eclipse.reddeer.swt.impl.button.BackButton) JobIsRunning(org.eclipse.reddeer.workbench.core.condition.JobIsRunning) DefaultCombo(org.eclipse.reddeer.swt.impl.combo.DefaultCombo) WorkbenchShell(org.eclipse.reddeer.workbench.impl.shell.WorkbenchShell) FinishButton(org.eclipse.reddeer.swt.impl.button.FinishButton) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) InternalBrowser(org.eclipse.reddeer.swt.impl.browser.InternalBrowser) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) ControlIsEnabled(org.eclipse.reddeer.swt.condition.ControlIsEnabled) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) Test(org.junit.Test)

Example 5 with InternalBrowser

use of org.eclipse.reddeer.swt.impl.browser.InternalBrowser in project jbosstools-openshift by jbosstools.

the class GetOpenShiftIOTokenTest method testGetToken.

@Test
public void testGetToken() {
    new DefaultToolItem(new WorkbenchShell(), "Connect to OpenShift.io").click();
    DefaultShell browser = new DefaultShell();
    InternalBrowser internalBrowser = new InternalBrowser(browser);
    new WaitWhile(new JobIsRunning(), TimePeriod.LONG);
    new WaitUntil(new BrowserContainsText("OpenShift.io Developer Preview"), TimePeriod.LONG);
    internalBrowser.execute(String.format("document.getElementById(\"username\").value=\"%s\"", DatastoreOS3.OPENSHIFT_IO_USERNAME));
    internalBrowser.execute(String.format("document.getElementById(\"password\").value=\"%s\"", DatastoreOS3.OPENSHIFT_IO_PASSWORD));
    internalBrowser.execute("document.getElementById(\"password\").parentElement.parentElement.parentElement.submit()");
    new WaitWhile(new JobIsRunning(), TimePeriod.LONG);
    try {
        new DefaultShell("OpenShift.io");
    } catch (CoreLayerException ex) {
        // Secure storage has been triggered
        SecureStorage.handleSecureStoragePasswordAndHint(SystemProperties.SECURE_STORAGE_PASSWORD);
        new DefaultShell("OpenShift.io");
    }
    new OkButton().click();
    checkAccountInProperties();
    checkPluginInSecureStorage();
}
Also used : OkButton(org.eclipse.reddeer.swt.impl.button.OkButton) WorkbenchShell(org.eclipse.reddeer.workbench.impl.shell.WorkbenchShell) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) InternalBrowser(org.eclipse.reddeer.swt.impl.browser.InternalBrowser) DefaultToolItem(org.eclipse.reddeer.swt.impl.toolbar.DefaultToolItem) BrowserContainsText(org.jboss.tools.openshift.reddeer.condition.BrowserContainsText) JobIsRunning(org.eclipse.reddeer.workbench.core.condition.JobIsRunning) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) CoreLayerException(org.eclipse.reddeer.core.exception.CoreLayerException) AbstractTest(org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest) Test(org.junit.Test)

Aggregations

InternalBrowser (org.eclipse.reddeer.swt.impl.browser.InternalBrowser)7 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)6 DefaultShell (org.eclipse.reddeer.swt.impl.shell.DefaultShell)6 ShellIsAvailable (org.eclipse.reddeer.swt.condition.ShellIsAvailable)4 DefaultToolItem (org.eclipse.reddeer.swt.impl.toolbar.DefaultToolItem)4 WorkbenchShell (org.eclipse.reddeer.workbench.impl.shell.WorkbenchShell)4 WaitWhile (org.eclipse.reddeer.common.wait.WaitWhile)3 Test (org.junit.Test)3 OkButton (org.eclipse.reddeer.swt.impl.button.OkButton)2 PushButton (org.eclipse.reddeer.swt.impl.button.PushButton)2 LabeledCombo (org.eclipse.reddeer.swt.impl.combo.LabeledCombo)2 JobIsRunning (org.eclipse.reddeer.workbench.core.condition.JobIsRunning)2 CentralIsLoaded (org.jboss.tools.openshift.reddeer.condition.CentralIsLoaded)2 AbstractTest (org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest)2 RedDeerException (org.eclipse.reddeer.common.exception.RedDeerException)1 CoreLayerException (org.eclipse.reddeer.core.exception.CoreLayerException)1 WithTextMatcher (org.eclipse.reddeer.core.matcher.WithTextMatcher)1 ControlIsEnabled (org.eclipse.reddeer.swt.condition.ControlIsEnabled)1 ShellIsActive (org.eclipse.reddeer.swt.condition.ShellIsActive)1 BackButton (org.eclipse.reddeer.swt.impl.button.BackButton)1