Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 更改隐藏元素的值_Html_Ruby_Watir - Fatal编程技术网

Html 更改隐藏元素的值

Html 更改隐藏元素的值,html,ruby,watir,Html,Ruby,Watir,如何使用ruby和watir单击隐藏复选框和/或更改隐藏元素的值(从“2”更改为“1”) html [div class="spec"] [span class="listheader"]Rechtsgebieden[/span] [div] [span class="legalarea" style="cursor:default" onmouseout="hlt(this,false);" onmouseover="hlt(this,true);" ondblclick="c

如何使用ruby和watir单击隐藏复选框和/或更改隐藏元素的值(从“2”更改为“1”)

html

 [div class="spec"]
  [span class="listheader"]Rechtsgebieden[/span]
  [div]
   [span class="legalarea" style="cursor:default" onmouseout="hlt(this,false);" onmouseover="hlt(this,true);" ondblclick="call(this, '.legalarea');" onclick="call(this, '.legalarea');"]
   [table id="ctl00_cphMC_SS_eJuris_fltrJurLegalArea_cbt" border="0"] [/table]
  [/div]
 [span class="legalarea-root " style="cursor:default" onmouseout="hlt(this,false);" onmouseover="hlt(this,true);"]
  [div id="ctl00_cphMC_SS_eJuris_fltrJurLegalArea_qwtA105qwausqwt_pu" class="CheckboxValuePopup" style="display:none;position:absolute;" name="ctl00-cphMC-SS-eJuris-fltrJurLegalArea-qwtA105qwausqwt-pu"] [/div]
 [span class="legalarea-root " style="cursor:default" onmouseout="hlt(this,false);" onmouseover="hlt(this,true);"]
  [input id="ctl00_cphMC_SS_eJuris_fltrJurLegalArea_qwtA109qwausqwt_cb_cv" type="hidden" value="2" name="ctl00$cphMC$SS$eJuris$fltrJurLegalArea$qwtA109qwausqwt$cb_cv"]
 [img ondblclick="CheckBox(this, '.ctl00-cphMC-SS-eJuris-fltrJurLegalArea-qwtA109qwausqwt-pu', true);" onclick="CheckBox(this, '.ctl00-cphMC-SS-eJuris-fltrJurLegalArea-qwtA109qwausqwt-pu', true);" src="http://portal.rechtsorde.nl/img/2.png"]
 [a class="search-filter-link" onclick="$('.ctl00-cphMC-SS-eJuris-fltrJurLegalArea-qwtA109qwausqwt-pu').dialog('open'); callerID=this;"]Handels- en ondernemingsrecht[/a]
用于访问元素/查找值的代码:

browser.hidden(:name, /A111/)first.value 

Watir不允许您更改隐藏元素的值。Watir正试图模拟一个实际用户。由于用户无法更改隐藏元素,Watir也无法更改。相反,您应该尝试与调用函数的元素交互以更改隐藏元素

所提供的html看起来有点笨拙(请参阅对问题的评论),但我的猜测是,当单击看起来像空白复选框字段的img时,隐藏值会发生变化

您可以尝试单击隐藏字段的同级图像:

browser.hidden(:name, /A111/).first.parent.img.click
鉴于隐藏字段的名称似乎是动态生成的,您可能还希望尝试以下操作(我认为这些操作基于不太可能更改的部分):


Watir不允许您更改隐藏元素的值。Watir正试图模拟一个实际用户。由于用户无法更改隐藏元素,Watir也无法更改。相反,您应该尝试与调用函数的元素交互以更改隐藏元素

所提供的html看起来有点笨拙(请参阅对问题的评论),但我的猜测是,当单击看起来像空白复选框字段的img时,隐藏值会发生变化

您可以尝试单击隐藏字段的同级图像:

browser.hidden(:name, /A111/).first.parent.img.click
鉴于隐藏字段的名称似乎是动态生成的,您可能还希望尝试以下操作(我认为这些操作基于不太可能更改的部分):


您可以使用JS来更改值


browser.execute_script('document.getElementById(“ctl00_cphMC_SS_eJuris_fltrJurLegalArea_qwta09qwausqwt_cb_cv”)。value=“1”)

您可以使用JS更改值


浏览器.ExcExtEyScript('Do.GETeleMyByID)(cTLMyCycMcS.ErruleRultRealLogalAlaaqQWTA109QWAUSSQWTBCBYCV)“值=“1”)

请考虑清理所提供的HTML(1)HTML应使用<和>,而不是[和];(2) 某些元素似乎嵌套不正确或缺少相应的打开/关闭标记,这可能表明缺少html;(3)没有隐藏的元素,名称为/a111/,看起来数字是动态生成的。请考虑清理所提供的HTML(1)HTML应该使用<和>,而不是[和];(2) 某些元素似乎嵌套不正确或缺少相应的打开/关闭标记,这可能表明缺少html;(3) 没有名为/A111/的隐藏元素,看起来该数字是动态生成的。第二个有效。谢谢你给出了非常清晰、非常有用的答案!第二个成功了。谢谢你给出了非常清晰、非常有用的答案!