[英]Not able to select the value from the pop-up which is similiar like dropdown -box
I have to select field which is similar like dropdown-box but not actual dropdown-box. 我必须选择类似于下拉框的字段,而不是实际的下拉框。 The select field shows value in pop-up which contains values and sub-values, I need to select values.
选择字段在包含值和子值的弹出窗口中显示值,我需要选择值。
Facing issues : 面临的问题:
Not able to identify the object and unable to select the value from the field. 无法识别对象,也无法从字段中选择值。
I have tried for cssSelector to identify object : " div[class='mailval'][title='Breast > Both'] ". 我已经尝试使用cssSelector来标识对象:“ div [class ='mailval'] [title ='Breast> Both'] ”。 It is not working.
它不起作用。
Following is the HTML Code : 以下是HTML代码:
<div class="rowDiv ">
<label for="bodypart">Body Part</label>
<div id="bodypart_box_1">
<div style="position:absolute;left:185px;z-index: 20">
<ul class="parent">
<li>
<div id="main" class="mailval">events=Object { click=[1]}handle=function()
<input id="bodypart_1" class="bodypart" type="text" onfocus="if($(this).hasClass('disabled')){$(this).blur();}" readonly="readonly" value="Select One" name="bodypart_1" title="">
<input id="actualBodypart_1" type="hidden" value="Breast" name="actualBodypart_1">
</div>
<ul id="bodyPartList_1" class="top sub bodyPartList" style="display: none;">olddisplay="block"
<li>
<div class="mailval fly" title="Breast" originaltitle="Breast">Breast</div>events=Object { click=[1], mouseover=[1]}handle=function()
<ul>
<li>
<div class="mailval" title="Breast > Both" originaltitle="Breast > NULL > Both">Both</div>events=Object { click=[1], mouseover=[1]}handle=function()
</li>
<li>
<div class="mailval" title="Breast > Left" originaltitle="Breast > NULL > Left">Left</div>events=Object { click=[1], mouseover=[1]}handle=function()
</li>
<li>
<div class="mailval" title="Breast > Right" originaltitle="Breast > NULL > Right">Right</div>events=Object { click=[1], mouseover=[1]}handle=function()
</li>
</ul>
</li>
</ul>
</li>
</ul>
<div style="clear:both"></div>
</div>
<p id="bodypart-error" class="errorMessage ml161px pa ie7ErrorFix" style="top:140px !important"></p>
</div>
The right way of using a class attribute in a selector is,it should be preceded by "." 在选择器中使用类属性的正确方法是,应在其前面加上“。”。
your selector can be rewritten as follows, 您的选择器可以如下重写:
div[title='Breast > Both'].mailval
you can try this selector as well, an id attribute should be preceded by "#" 您也可以尝试使用此选择器, id属性前应加上“#”
#bodyPartList_1 > div div[title='Breast > Both'].mailval
refer this to learn more about selectors 请参阅此内容以了解有关选择器的更多信息
EDIT : As per your html, the popup only appears when hovered over or clicked. 编辑:根据您的html,仅将鼠标悬停或单击时,才会显示弹出窗口。 This action can be performed using
JavascriptExecuter
, 可以使用
JavascriptExecuter
执行此操作,
((JavascriptExecutor)driver).executeScript("$('#bodyPartList_1 > .mailval.fly').click();");
Now the popup will be displayed, you just have to select the desired value... 现在将显示弹出窗口,您只需要选择所需的值即可。
new WebDriverWait(driver,20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[title='Breast > Both'].mailval"))).click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.