首页 文章

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

提问于
浏览
0

我正在开发一个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"/>

图片:enter image description here

手动单击图像后,将显示以下列表项 .

<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>

我尝试了以下选项来点击下拉列表旁边的图片 .

Code1: int xOffset = 0,yOffset = 0;动作动作=新动作(驱动程序);
WebElement TreeObj = driver.findElement(By.xpath("//*[@id='widget_dijit_form_FilteringSelect_1']/descendant::input[@type='image']")); actions.moveToElement(TreeObj,xOffset,yOffset);
. actions.moveToElement(TreeObj) . 单击() Build ()执行();

Code2: driver.findElement(By.xpath("//*[@id='widget_dijit_form_FilteringSelect_1']/descendant::input[@type='image']")) . click();

Code3:
driver.findElement(By.xpath(“(// input [@ type = 'image'])2”)) . click();

请求其他人调查并帮助我点击对象以从列表框中选择项目 .

2 回答

  • 0

    使用普通操作类或单击方法无法处理下拉菜单 . 我们需要使用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

    回复是否运行 . 快乐学习:-)

  • 0

    最后,我可以找到一个在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);
    		    }
    		 }
    

相关问题