无法单击IBM BPM列表框的下拉图像

Unable to click on a dropdown image of a IBM BPM listbox

本文关键字:图像 列表 单击 IBM BPM      更新时间:2023-09-26

我正在开发一个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);
		    }
		 }