Is it possible to assign id or name to <select> rendered from Jelly's dropdownList?

37 views
Skip to first unread message

Kirill

unread,
Jun 27, 2015, 2:41:05 AM6/27/15
to jenkin...@googlegroups.com
Hi developers,

Is it possible to assign id or name to <select> rendered from Jelly's dropdownList?

I'm struggling to test form submission as described in https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test - but I can't locate my <select>! I need it to test the hetero-list functionality.

I have <f:dropdownList name="testArtifacts" title="Define test artifact as"> in my config.jelly. However, when it's being rendered, I get a <select class="setting-input dropdownList">, without name. It's absolutely useless, as there's about 20 different HTML dropdowns in my plugin with the same CSS classes. How am I supposed to find mine?

I tried to wrap it into <f:entry field="..">, but that doesn't help as well. It would be handy if ID attribute could be used, but IMHO it's not supported, is it?

Jesse Glick

unread,
Jun 27, 2015, 12:16:57 PM6/27/15
to Jenkins Dev
On Sat, Jun 27, 2015 at 2:41 AM, Kirill <yam...@gmail.com> wrote:
> It would be handy if ID attribute could be used

Try adding a test-scoped dependency on
org.jenkins-ci.plugins:form-element-path like the
acceptance-test-harness does.

Kirill

unread,
Jul 2, 2015, 2:37:56 AM7/2/15
to jenkin...@googlegroups.com
Thanks for suggestion, Jesse!
I added the dependency to my Maven POM:

<dependency>
    <groupId>org.jenkins-ci.plugins</groupId>
    <artifactId>form-element-path</artifactId>
    <version>1.5</version>
    <scope>test</scope>
</dependency>

After this I noticed that inputs on config page have IDs (not sure how constant they are though).

But this caused the problem with config form loading. I have this code:

JenkinsRule context = context();
JenkinsRule.WebClient webClient = context.createWebClient();
webClient.getPage(freeStyleProject, "configure");

When webClient.getPage() is called, the following appears in Jenkins log:

Jul 02, 2015 7:12:12 AM com.gargoylesoftware.htmlunit.WebClient printContentIfNecessary
INFO: <html><body>
<h1>404 Not Found</h1>
<p>Stapler processed this HTTP request as follows, but couldn't find the resource to consume the request
<pre>
-> evaluate(&lt;hudson.model.Hudson@3766c667> :hudson.model.Hudson,"/plugin/form-element-path/script.js")
-> evaluate(((StaplerProxy)&lt;hudson.model.Hudson@3766c667>).getTarget(),"/plugin/form-element-path/script.js")
-> evaluate(&lt;hudson.model.Hudson@3766c667>.getPlugin("form-element-path"),"/script.js")
<font color=red>-&gt; unexpected null!</font>
</pre>
<p>If this 404 is unexpected, double check the last part of the trace to see if it should have evaluated to null.
</body></html>

com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 Not Found for http://localhost:51648/jenkins/static/93ae3bc9/plugin/form-element-path/script.js
    at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:549)
    at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:998)
    at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:953)
    at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:359)
    at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:223)
    at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:238)
    at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:699)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:657)
    at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1132)
    at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1034)
    at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206)
    at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:329)
    at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3058)
    at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:1994)
    at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:907)
    at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)
    at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:901)
    at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:350)
    at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:304)
    at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:134)
    at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:101)
    at org.jvnet.hudson.test.HudsonPageCreator.createPage(HudsonPageCreator.java:46)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:449)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:332)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:374)
    at org.jvnet.hudson.test.JenkinsRule$WebClient.goTo(JenkinsRule.java:2016)
    at org.jvnet.hudson.test.JenkinsRule$WebClient.goTo(JenkinsRule.java:1996)
    at org.jvnet.hudson.test.JenkinsRule$WebClient.getPage(JenkinsRule.java:1956)

In a weird way, inability to load this JS resource interrupts the test with exception.

Regards,
Kirill.

суббота, 27 июня 2015 г., 17:16:57 UTC+1 пользователь Jesse Glick написал:
Reply all
Reply to author
Forward
0 new messages