use of com.gargoylesoftware.htmlunit.html.HtmlElement in project selenium_java by sergueik.
the class WhenBrowsingReportsList method checkReportHyperlinks.
private void checkReportHyperlinks(final HtmlTableRow row) {
List<HtmlElement> elements = row.getCell(0).getHtmlElementsByTagName("a");
Assert.assertEquals("Unexpected number of anchor elements for report icon", 1, elements.size());
final HtmlAnchor iconAnchor = (HtmlAnchor) elements.get(0);
elements = row.getCell(1).getHtmlElementsByTagName("a");
Assert.assertEquals("Unexpected number of anchor elements for report title", 1, elements.size());
final HtmlAnchor titleAnchor = (HtmlAnchor) elements.get(0);
Assert.assertEquals("Hyperlinks must not be different between report icon and report title", iconAnchor.getHrefAttribute(), titleAnchor.getHrefAttribute());
}
use of com.gargoylesoftware.htmlunit.html.HtmlElement in project selenium_java by sergueik.
the class AbstractJenkinsPage method getElement.
public HtmlElement getElement(final HtmlElement container, final String tagName, final String textContent) {
LOGGER.log(Level.INFO, String.format("Looking into container '%s' for element '%s' with content '%s'", container, tagName, textContent));
final List<HtmlElement> elements = container.getElementsByTagName(tagName);
HtmlElement retval = null;
// find the save button (it has no predictable id)
for (final HtmlElement element : elements) {
if (element.getTextContent().trim().equalsIgnoreCase(textContent)) {
retval = element;
break;
}
}
LOGGER.log(Level.INFO, String.format("Found %s", retval));
return retval;
}
use of com.gargoylesoftware.htmlunit.html.HtmlElement in project selenium_java by sergueik.
the class JenkinsConfigurationPage method getSecurityMatrix.
private HtmlTable getSecurityMatrix() {
// enable security
final HtmlElement useSecurity = configForm.getInputByName("_.useSecurity");
try {
useSecurity.click();
} catch (final IOException e) {
throw new RuntimeException(e);
}
// use matrix-based security
final List<HtmlInput> authorizationInputs = configForm.getInputsByName("authorization");
HtmlInput useMatrixSecurityRadioBtn = null;
for (final HtmlInput input : authorizationInputs) {
if (input.getValueAttribute().equals("3")) {
useMatrixSecurityRadioBtn = input;
break;
}
}
try {
useMatrixSecurityRadioBtn.click();
} catch (IOException e) {
throw new RuntimeException(e);
}
return (HtmlTable) configForm.getOwnerDocument().getElementById("hudson-security-GlobalMatrixAuthorizationStrategy");
}
use of com.gargoylesoftware.htmlunit.html.HtmlElement in project JSCover by tntim96.
the class HtmlServerUnloadedJSProxyOnlyInstrumentRegTest method shouldIncludeUnloadJSInSavedReport.
@Test
public void shouldIncludeUnloadJSInSavedReport() throws Exception {
File jsonFile = new File(reportDir + "/jscoverage.json");
if (jsonFile.exists())
jsonFile.delete();
HtmlPage page = webClient.getPage("http://localhost:9001/jscoverage.html?index.html");
page.getHtmlElementById("summaryTab").click();
webClient.waitForBackgroundJavaScript(2000);
assertEquals("75%", page.getElementById("summaryTotal").getTextContent());
verifyCoverage(page, "/level1/level1.js", "75%", "50%", "N/A");
page.getHtmlElementById("storeTab").click();
webClient.waitForBackgroundJavaScript(500);
HtmlElement storeButton = page.getHtmlElementById("storeButton");
storeButton.click();
webClient.waitForBackgroundJavaScript(2000);
String result = page.getElementById("storeDiv").getTextContent();
assertThat(result, containsString("Coverage data stored at " + new File(reportDir).getPath()));
String json = ioUtils.toString(jsonFile);
assertThat(json, not(containsString("/root.js")));
assertThat(json, containsString("/level1/level1.js"));
assertThat(json, containsString("/level1/level2/level2.js"));
String url = "file:///" + new File(reportDir + "/jscoverage.html").getAbsolutePath();
page = webClient.getPage(url);
webClient.waitForBackgroundJavaScript(1000);
assertEquals("37%", page.getElementById("summaryTotal").getTextContent());
assertEquals("25%", page.getElementById("branchSummaryTotal").getTextContent());
assertEquals("0%", page.getElementById("functionSummaryTotal").getTextContent());
verifyCoverage(page, "/level1/level1.js", "75%", "50%", "N/A");
verifyCoverage(page, "/level1/level2/level2.js", "0%", "0%", "0%");
}
use of com.gargoylesoftware.htmlunit.html.HtmlElement in project promoted-builds-plugin by jenkinsci.
the class ManualConditionBug22005 method testPromotionProcessViaWebClient.
@Test
public void testPromotionProcessViaWebClient() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
ExtensionList<Descriptor> list = j.jenkins.getExtensionList(Descriptor.class);
list.add(new JobPropertyImpl.DescriptorImpl(JobPropertyImpl.class));
JobPropertyImpl base = new JobPropertyImpl(p);
p.addProperty(base);
createPromotionProcess(base, "PROM0");
createPromotionProcess(base, "PROM1");
createPromotionProcess(base, "PROM2");
FreeStyleBuild b1 = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
assertNull(b1.getAction(ManualApproval.class));
HtmlPage page = j.createWebClient().getPage(b1, "promotion");
// Approve Promotion
List<HtmlForm> forms = ManualConditionTest.getFormsByName(page, "approve");
assertFalse(forms.isEmpty());
assertEquals(3, forms.size());
for (HtmlForm form : forms) {
submit(form);
}
// reload promotions page
page = j.createWebClient().getPage(b1, "promotion");
forms = ManualConditionTest.getFormsByName(page, "build");
for (HtmlForm form : forms) {
List<HtmlElement> parameters = ManualConditionTest.getFormParameters(form);
assertEquals(2, parameters.size());
}
}
Aggregations