[英]Htmlunit selecting input running Dojo javascript package
So I am trying to access a textbox in order to change the box from the default "Select Customer" to "PE". 因此,我试图访问文本框,以将框从默认的“选择客户”更改为“ PE”。 My issue is the element is recognized by Htmlunit as a HtmlTextInput rather than HtmlSelection.
我的问题是Htmlunit将元素识别为HtmlTextInput而不是HtmlSelection。 I have learned that it runs dojo which complicates things a bit.
我了解到它运行dojo会使事情变得有些复杂。
Here is the snippet of code I am trying to manipulate. 这是我尝试操作的代码段。
<form action="#" method="GET">
<span class="headlines">Customer:</span>
<select id="orgSelect"
name="orgSelect"
dojoType="dijit.form.FilteringSelect"
labelType="text"
style="width: 150px;visibility:hidden"
autoComplete="true"
<option value="__select__" selected>Select Customer</option>
<option value="-1">**All Customers**</option>
<option value="2396-1986">PCLP</option>
<option value="3-1987">PE</option>
<option value="8262-1988">PEA</option>
My code is 我的代码是
List <HtmlForm> f= page.getForms();
HtmlTextInput ba = f.get(0).getInputByName("orgSelect");
ba.setValueAttribute("PE");
Here is what the Text version looks like. 这是文本版本的外观。
Customer: Select CustomerPE 客户:选择CustomerPE
? ?
Report Category: Select Report Category_ select _ 报告类别:选择报告类别_ 选择 _
You can't set HtmlSelect directly. 您不能直接设置HtmlSelect。
You simply need to 'select' the good option within the select. 您只需要在选择中“选择”好的选项。
eg : 例如:
HtmlSelect select = page.getHtmlElementById("myId");
for (HtmlOption o : select.getOptions()) {
if (o.getValueAttribute().contains("myValue")) {
select.setSelectedAttribute(o, true);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.