V Teja
V Teja

Reputation: 1

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

I am working on a IBM BPM portal which has the following drop down arrow next to a list box, requires a click to display list items in the DOM structure.

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

Image: enter image description here

After clicking on the Image manually, following list items appears.

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

I have tried following options to click on the image next to dropdown.

Code1: int xOffset = 0, yOffset = 0; Actions actions = new Actions(driver);
WebElement TreeObj=driver.findElement(By.xpath("//*[@id='widget_dijit_form_FilteringSelect_1']/descendant::input[@type='image']")); actions.moveToElement(TreeObj, xOffset, yOffset);
actions.moveToElement(TreeObj).click().build().perform();

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();

Request others to investigate and help me clicking on the objects to select items from the listbox.

Upvotes: 0

Views: 246

Answers (2)

V Teja
V Teja

Reputation: 1

Finally I could figure out a solution to perform actions on a BPM listbox. Thanks Kishan for spending some time,your suggestion might be useful for other web objects but not for BPM list boxes.

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);
		    }
		 }	

Upvotes: 0

Kishan Patel
Kishan Patel

Reputation: 1383

Drop down cannot be handled using normal action class or click method. We need to use Select Class for it.

So just try out this..

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");

There are other methods also to select values from drop down, I am showing you visible text method.. Just try to run this. Hope it will help you..

Do go through this link. It is very helpful..

https://www.seleniumeasy.com/selenium-tutorials/webdriver-select-methods-to-work-with-dropdowns

Do reply whether it ran or not. Happy Learning :-)

Upvotes: 0

Related Questions