无法填写“隐藏的文字"区域元素 [英] Can't fill in the Hidden text area element
问题描述
F1,需要使用Robotframework的隐藏元素的帮助或提示.
问题在于要填充文本区域中的任何文本,我需要将文本区域的状态从display:none;
to display:block;
F1, need some help or hints with Hidden element using Robotframework.
The problem consist that to fill any text in the text area, I need to change the state of text area from display:none;
to display:block;
代码本身:
<div class="col-md-12">
<div class="cazary" style="width: 664px;">
<div class="cazary-commands-wrapper">
<ul class="cazary-commands-list">
<li unselectable="on" title="Size" class="cazary-command-fontsize">Size</li>
</ul>
<ul class="cazary-commands-list">
<li unselectable="on" title="Foreground Color" class="cazary-command-forecolor">Foreground Color</li>
</ul>
<ul class="cazary-commands-list">
<li unselectable="on" title="Background Color" class="cazary-command-backcolor">Background Color</li>
</ul>
<ul class="cazary-commands-list">
<li unselectable="on" title="Remove Format" class="cazary-command-removeformat">Remove Format</li>
</ul>
</div>
<iframe class="cazary-edit" src="javascript:" style="height: 39px;"></iframe>
<textarea id="summernote" class="required-preview field cazary-source" placeholder="Tell us all about your Advertisement. This description will be prominently displayed in your Advertisement notice. Feel free to adjust the fonts and background colour too." name="observations" cols="50" rows="10" style="display: none;"></textarea>
</div>
我的Robotframework代码尝试:
My Robotframework code tries:
Select Frame //iframe[@class="cazary-edit"]
# First try
Input text //textarea[@id="summernote"] ${UniversalVariableforName}
# Second try
Input text //iframe[@class="cazary-edit"] ${UniversalVariableforName}
# Third try
Input text //div[@class="cazary"]//iframe[@class="cazary-edit"] ${UniversalVariableforName}
# Fourth try
Input text //body[@class="empty"] ${UniversalVariableforName}
# Fifth try
Input text //iframe[@class="cazary-edit"]//body[@class="empty"] ${UniversalVariableforName}
返回的错误: 图像
可能存在使用 Execute Javascript 关键字的解决方案吗?
May be there is a solution with Execute Javascript keyword?
推荐答案
相关的 <textarea>
在 <iframe class="cazary-edit">
之外.因此,我们无需切换到 <iframe>
The concerned <textarea>
is outside of the <iframe class="cazary-edit">
. Hence we don't need to switch to the <iframe>
要将文本发送到 Input
字段,您可以尝试:
To send the text to the Input
field you can try to :
-
将
xpath
用作:
"//textarea[@class='required-preview field cazary-source' and @id='summernote']"
Click
首先是 Input
字段.
Click
the Input
field first.
由于相关的textarea
的style
属性设置为 "display: none;"
,因此我们必须通过 JavascriptExecutor
更改为 "display: block;"
,然后发送文字.
As the concerned textarea
have the style
attribute set as "display: none;"
, we have to change to "display: block;"
through JavascriptExecutor
then send the text.
driver.execute_script("document.getElementById('ID').style.display='block';")
这篇关于无法填写“隐藏的文字"区域元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!