简体   繁体   English

无法从类似于下拉框的弹出窗口中选择值

[英]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.

相关问题 如何从弹出窗口中的下拉菜单中选择值 - How to select the value from drop down present on pop-up 如何通过Selenium从下载弹出框中保存文件? - How to save file by Selenium from download pop-up box? 无法使用Java切换到弹出窗口并在Webdriver中找到弹出窗口中的任何元素 - Not able to switch to pop-up window and find any elements in pop-up in Webdriver using Java 是否可以从Java程序内部捕获Windows弹出消息框? - Is it possible to capture a Windows pop-up message box from inside a Java program? 控制jtable的AutoFilterTableHeader的弹出(下拉)菜单大小 - Controlling pop-up (dropdown) menu size of a AutoFilterTableHeader for a jtable 无法在appium中单击权限弹出窗口(访问联系人列表) - Not able to click on permission pop-up (Access Contact List) in appium 无法识别 Selenium Webdriver 中的元素(skynews 上的 cookie 弹出窗口) - Not able to identify an element in Selenium Webdriver (cookies pop-up on skynews) 带表单的弹出对话框停留在提交状态 - pop-up dialog box w/ form stays upon Submit .NET弹出框术语以及Java - .NET pop-up box terminology along with Java 带有 Null 指针异常的弹出对话框中的 Recycler View - Recycler View in a pop-up Dialog box with a Null Pointer Exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM