无法单击IBM BPM列表框的下拉图像
Unable to click on a dropdown image of a IBM BPM listbox
我正在开发一个IBM BPM门户,该门户在列表框旁边有以下下拉箭头,需要单击才能在DOM结构中显示列表项。
<div class="dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer dijitDownArrowButtonHover" role="presentation" data-dojo-attach-point="_buttonNode, _popupStateNode">
<input class="dijitReset dijitInputField dijitArrowButtonInner" type="image" role="presentation" readonly="readonly" tabindex="-1" alt="" src="/teamworks/script/coachNG/dojo/1.8.6/dojo/resources/blank.gif"/>
图片:在此处输入图像描述
手动单击图像后,将显示以下列表项。
<div id="dijit_form_FilteringSelect_1_popup_prev" class="dijitMenuItem dijitMenuPreviousButton" role="option" data-dojo-attach-point="previousButton" style="display: none;">Previous choices</div>
<div id="dijit_form_FilteringSelect_1_popup0" class="dijitReset dijitMenuItem" role="option" item="0">--- Select ---</div>
<div id="dijit_form_FilteringSelect_1_popup1" class="dijitReset dijitMenuItem" role="option" item="1">CJA Coversheet</div>
<div id="dijit_form_FilteringSelect_1_popup2" class="dijitReset dijitMenuItem" role="option" item="2">Correspondence</div>
<div id="dijit_form_FilteringSelect_1_popup3" class="dijitReset dijitMenuItem" role="option" item="3">Proof of Address</div>
<div id="dijit_form_FilteringSelect_1_popup4" class="dijitReset dijitMenuItem" role="option" item="4">Proof of Identity</div>
<div id="dijit_form_FilteringSelect_1_popup_next" class="dijitMenuItem dijitMenuNextButton" role="option" data-dojo-attach-point="nextButton" style="display: none;">More choices</div>
我尝试了以下选项来点击下拉列表旁边的图像。
代码1:int xOffset=0,yOffset=0;Actions Actions=新的Actions(驱动程序)
WebElement TreeObj=driver.findElement(By.xpath("//*[@id='idget_dijit_form_FilteringSelect_1']/descendant::input[@type='image']");actions.moveToElement(TreeObj,xOffset,yOffset)
actions.moveToElement(TreeObj).click().build().perform();
代码2:driver.findElement(By.xpath("//*[@id='idget_dijit_form_FilteringSelect_1']/descendant::input[@type='image']").click();
代码3:
driver.findElement(By.xpath("(//input[@type='image'])2").click();
请求其他人调查并帮助我点击对象从列表框中选择项目。
不能使用普通操作类或单击方法处理下拉。我们需要使用Select Class。
所以试试这个。。
Webelement someobject = driver.findElement(By.xpath("//*[@id='widget_dijit_form_FilteringSelect_1']/descendant::input[@type='image']"));
Select select = new Select(someobject);
someobject.selectByVisibleText("CJA Coversheet");
还有其他方法可以从下拉列表中选择值,我向您展示了可见文本方法。。试着运行这个。希望它能帮助你。。
请浏览此链接。这很有帮助。。
https://www.seleniumeasy.com/selenium-tutorials/webdriver-select-methods-to-work-with-dropdowns
无论是否运行,都要回复。快乐学习:-)
最后,我可以找到一个在BPM列表框上执行操作的解决方案。感谢Kishan花了一些时间,您的建议可能对其他web对象有用,但对BPM列表框不有用。
String parameter = "--- Select ---;CJA Coversheet;Correspondence;Proof of Address;Proof of Identity";
String[] splitparameter= parameter.split(";");
WebElement fr = driver.findElement(By.xpath("//iframe[@dojoattachpoint='frame']"));
driver.switchTo().frame(fr);
//driver.findElement(By.xpath("(//input[@type='image'])[1]")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='dijit_form_FilteringSelect_0']")).clear();
driver.findElement(By.xpath("//*[@id='dijit_form_FilteringSelect_0']")).sendKeys("CJA");
driver.findElement(By.xpath("//*[@id='widget_dijit_form_FilteringSelect_1']/descendant::input[@type='image']")).click();
driver.findElement(By.xpath("//*[@id='dijit_form_FilteringSelect_1']")).clear();
WebElement TreeObj=driver.findElement(By.xpath("//*[@id='widget_dijit_form_FilteringSelect_1']/descendant::input[@type='image']"));
//..................................................................................................................
int xOffset = 2, yOffset = 2;
Actions actions = new Actions(driver);
actions.moveToElement(TreeObj, xOffset, yOffset).click().build().perform();
Thread.sleep(2000);
List<WebElement> allListOptions = driver.findElements(By.xpath("//div[contains(@id,'FilteringSelect_1')]/descendant::div[contains(@id,'FilteringSelect') and @role='option' and @item>='0']"));
//allListOptions.get(0).getText()
for (int i = 0; i < splitparameter.length; i++) {
String optionValue = allListOptions.get(i).getText();
if (optionValue.equals(splitparameter[i])) {
System.out.println("Value verified with the expected value: "+ optionValue);
} else {
System.out.println("Failed to verify value with the expected value: "+ optionValue);
}
}
- 如何从 URL 数组向文档添加图像列表
- 如何创建背景图像列表'URL,并使用jQuery在单击函数时应用它们
- 网页上已有tinymce加载图像列表
- 如何使用javascript获取文件夹中的图像列表
- 使用JavaScript或JQuery从cloudinary获取图像列表
- 调用照片在图像列表上滑动的简单方法
- JQuery 和 Bootstrap:如何将图像列表中的图像添加到轮播
- 包含文本和 URL 的图像列表视图
- 按图像计数变量显示图像列表
- 在段落列表后插入图像列表
- 在哪里可以找到dojo工具箱dijit小部件的图标图像列表
- 在 Node.js 中使用 OpenCV 加载图像列表
- 如何让jQuery等待图像列表加载后再处理它们
- 如何使用jquery从图像列表中获取单击图像的属性
- 带有Angular和Angular材质的图像列表
- 如何在web编程中显示适合屏幕的图像列表
- 如何从客户端 JavaScript 从 cloudinary 获取我的图像列表
- 在图像列表中导航的最简单方法是什么?
- 如何在图像列表中移动元素?与JQuery
- 按顺序加载图像列表