Search in sources :

Example 11 with HtmlRadioButtonInput

use of com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput in project faces by jakartaee.

the class Issue2767IT method testCommandLinkRadio.

/**
 * @see AjaxBehavior
 * @see https://github.com/eclipse-ee4j/mojarra/issues/2771
 */
@Test
public void testCommandLinkRadio() throws Exception {
    HtmlPage page = getPage("issue2767.xhtml");
    HtmlAnchor anchor = (HtmlAnchor) page.getElementById("testLink");
    // This will ensure JavaScript finishes before evaluating the page.
    webClient.waitForBackgroundJavaScript(3000);
    anchor.click();
    webClient.waitForBackgroundJavaScript(3000);
    assertTrue(page.asXml().contains("LINK ACTION"));
    HtmlRadioButtonInput radio1 = (HtmlRadioButtonInput) page.getElementById("testRadio:0");
    HtmlRadioButtonInput radio2 = (HtmlRadioButtonInput) page.getElementById("testRadio:1");
    HtmlRadioButtonInput radio3 = (HtmlRadioButtonInput) page.getElementById("testRadio:2");
    page = radio1.click();
    webClient.waitForBackgroundJavaScript(3000);
    assertTrue(page.asXml().contains("RADIO:red"));
    page = radio2.click();
    webClient.waitForBackgroundJavaScript(3000);
    assertTrue(page.asXml().contains("RADIO:blue"));
    page = radio3.click();
    webClient.waitForBackgroundJavaScript(3000);
    assertTrue(page.asXml().contains("RADIO:white"));
}
Also used : HtmlAnchor(com.gargoylesoftware.htmlunit.html.HtmlAnchor) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlRadioButtonInput(com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput) Test(org.junit.Test)

Example 12 with HtmlRadioButtonInput

use of com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput in project faces by jakartaee.

the class Issue2408IT method testSelectOneRadioIdsInComposite.

/**
 * This test verifies correct function of SelectOneRadio in a Composite
 * Component over Ajax. The components in the page have ids.
 */
@Test
public void testSelectOneRadioIdsInComposite() throws Exception {
    HtmlPage page = getPage("selectOneRadioIdsInComposite.xhtml");
    // This will ensure JavaScript finishes before evaluating the page.
    webClient.waitForBackgroundJavaScript(3000);
    assertTrue(page.asXml().contains("Status: Pending"));
    HtmlRadioButtonInput radio1 = (HtmlRadioButtonInput) page.getElementById("form:compId:radio:0");
    page = radio1.click();
    webClient.waitForBackgroundJavaScript(3000);
    assertTrue(page.asXml().contains("Status: radio-1"));
    HtmlRadioButtonInput radio2 = (HtmlRadioButtonInput) page.getElementById("form:compId:radio:1");
    page = radio2.click();
    webClient.waitForBackgroundJavaScript(3000);
    assertTrue(page.asXml().contains("Status: radio-2"));
    HtmlRadioButtonInput radio3 = (HtmlRadioButtonInput) page.getElementById("form:compId:radio:2");
    page = radio3.click();
    webClient.waitForBackgroundJavaScript(3000);
    assertTrue(page.asXml().contains("Status: radio-3"));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlRadioButtonInput(com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput) Test(org.junit.Test)

Example 13 with HtmlRadioButtonInput

use of com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput in project faces by jakartaee.

the class Issue4330IT method testIssue4330.

/**
 * @see HtmlSelectManyCheckbox
 * @see UISelectItem#isItemDisabled()
 * @see https://github.com/eclipse-ee4j/mojarra/issues/4330
 */
@Test
public void testIssue4330() throws Exception {
    HtmlPage page;
    HtmlRadioButtonInput disabledRadio;
    HtmlCheckBoxInput enabledCheckbox;
    HtmlCheckBoxInput disabledCheckbox;
    HtmlButtonInput hack;
    HtmlSubmitInput submit;
    page = getPage("issue4330.xhtml");
    assertTrue(page.getHtmlElementById("form:result").asNormalizedText().isEmpty());
    disabledRadio = page.getHtmlElementById("form:one:1");
    enabledCheckbox = page.getHtmlElementById("form:many:0");
    disabledCheckbox = page.getHtmlElementById("form:many:1");
    hack = page.getHtmlElementById("form:hack");
    submit = page.getHtmlElementById("form:submit");
    assertTrue(disabledRadio.isDisabled());
    assertTrue(disabledCheckbox.isDisabled());
    hack.click();
    webClient.waitForBackgroundJavaScript(1000);
    assertFalse(disabledRadio.isDisabled());
    assertFalse(disabledCheckbox.isDisabled());
    disabledRadio.setChecked(true);
    enabledCheckbox.setChecked(true);
    disabledCheckbox.setChecked(true);
    page = submit.click();
    // Thus not "disabled[enabled, disabled]"
    assertTrue(page.getHtmlElementById("form:result").asNormalizedText().equals("[enabled]"));
}
Also used : HtmlCheckBoxInput(com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlSubmitInput(com.gargoylesoftware.htmlunit.html.HtmlSubmitInput) HtmlRadioButtonInput(com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput) HtmlButtonInput(com.gargoylesoftware.htmlunit.html.HtmlButtonInput) Test(org.junit.Test)

Example 14 with HtmlRadioButtonInput

use of com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput in project throttle-concurrent-builds-plugin by jenkinsci.

the class ThrottleQueueTaskDispatcherTest method configureNewNodeWithLabel.

private void configureNewNodeWithLabel(String label) throws IOException {
    URL url = new URL(r.getURL() + "computer/new");
    HtmlPage page = r.createWebClient().getPage(url);
    HtmlForm form = page.getFormByName("createItem");
    HtmlInput input = form.getInputByName("name");
    input.setValueAttribute("test");
    List<HtmlRadioButtonInput> radios = form.getRadioButtonsByName("mode");
    for (HtmlRadioButtonInput radio : radios) {
        radio.setChecked(radio.getValueAttribute().equals("hudson.slaves.DumbSlave"));
    }
    page = submitForm(form);
    boolean buttonFound;
    List<HtmlForm> forms = page.getForms();
    for (HtmlForm aForm : forms) {
        if (aForm.getActionAttribute().equals("doCreateItem")) {
            form = aForm;
            break;
        }
    }
    input = form.getInputByName("_.numExecutors");
    input.setValueAttribute("1");
    input = form.getInputByName("_.remoteFS");
    input.setValueAttribute("/");
    input = form.getInputByName("_.labelString");
    input.setValueAttribute(label);
    List<HtmlButton> buttons = HtmlUnitHelper.getButtonsByXPath(form, buttonsXPath);
    buttonFound = buttonFoundThusFormSubmitted(form, buttons, saveButtonText);
    failWithMessageIfButtonNotFoundOnPage(buttonFound, saveButtonText, url);
}
Also used : HtmlForm(com.gargoylesoftware.htmlunit.html.HtmlForm) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlInput(com.gargoylesoftware.htmlunit.html.HtmlInput) HtmlRadioButtonInput(com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput) URL(java.net.URL) HtmlButton(com.gargoylesoftware.htmlunit.html.HtmlButton)

Example 15 with HtmlRadioButtonInput

use of com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput in project throttle-concurrent-builds-plugin by jenkinsci.

the class ThrottleQueueTaskDispatcherTest method configureJobThrottling.

private void configureJobThrottling(FreeStyleProject project) throws IOException {
    URL url = new URL(r.getURL() + project.getUrl() + configUrlSuffix);
    HtmlPage page = r.createWebClient().getPage(url);
    HtmlForm form = page.getFormByName(configFormName);
    List<HtmlButton> buttons = HtmlUnitHelper.getButtonsByXPath(form, buttonsXPath);
    String buttonText = saveButtonText;
    boolean buttonFound = false;
    for (HtmlButton button : buttons) {
        if (button.getTextContent().equals(buttonText)) {
            buttonFound = true;
            String checkboxName = "throttleEnabled";
            HtmlElement checkbox = page.getElementByName(checkboxName);
            assertNotNull(checkboxName + " checkbox not found on test job config page; plugin installed?", checkbox);
            checkbox.click();
            List<HtmlRadioButtonInput> radios = form.getRadioButtonsByName("throttleOption");
            for (HtmlRadioButtonInput radio : radios) {
                radio.setChecked(radio.getValueAttribute().equals("category"));
            }
            checkbox = page.getElementByName("categories");
            checkbox.click();
            button.click();
            break;
        }
    }
    failWithMessageIfButtonNotFoundOnPage(buttonFound, buttonText, url);
}
Also used : HtmlForm(com.gargoylesoftware.htmlunit.html.HtmlForm) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlElement(com.gargoylesoftware.htmlunit.html.HtmlElement) HtmlRadioButtonInput(com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput) URL(java.net.URL) HtmlButton(com.gargoylesoftware.htmlunit.html.HtmlButton)

Aggregations

HtmlRadioButtonInput (com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput)16 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)11 Test (org.junit.Test)8 HtmlCheckBoxInput (com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput)6 DomElement (com.gargoylesoftware.htmlunit.html.DomElement)4 HtmlButton (com.gargoylesoftware.htmlunit.html.HtmlButton)4 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)4 HtmlInput (com.gargoylesoftware.htmlunit.html.HtmlInput)4 DomNode (com.gargoylesoftware.htmlunit.html.DomNode)3 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)3 BrowserVersion (com.gargoylesoftware.htmlunit.BrowserVersion)2 TextPage (com.gargoylesoftware.htmlunit.TextPage)2 StyleElement (com.gargoylesoftware.htmlunit.css.StyleElement)2 BaseFrameElement (com.gargoylesoftware.htmlunit.html.BaseFrameElement)2 HtmlAnchor (com.gargoylesoftware.htmlunit.html.HtmlAnchor)2 HtmlButtonInput (com.gargoylesoftware.htmlunit.html.HtmlButtonInput)2 HtmlTextArea (com.gargoylesoftware.htmlunit.html.HtmlTextArea)2 Element (com.gargoylesoftware.htmlunit.javascript.host.Element)2 HTMLBodyElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBodyElement)2 HTMLCanvasElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCanvasElement)2