0

I'm testing the GUI on my application with Selenium 2.0.

The suggestbox apprears when i type data into an input field, and i need to click on the suggestbox to validate the input.

Image here : Image

My html code (input) :

<table class="supplier" cellspacing="1" width="100%">
<tbody>
<tr>
<td><span id="supplier:supplierOps" class="ui-autocomplete">
<input id="supplier:supplierOps_input" name="supplier:supplierOps_input" type="text" class="ui-autocomplete-input ui-inputfield ui-widget ui-state-default ui-corner-all" autocomplete="off" value="" size="10" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false">
</span></td>
<td>...</td>
</tr>
</tbody>
</table>

My html code (suggestBox) :

<table class="ui-autocomplete-items ui-autocomplete-table ui-widget-content ui-widget ui-corner-all ui-helper-reset">
<tbody>
<tr class="ui-autocomplete-item ui-autocomplete-row ui-corner-all ui-state-highlight" data-item-value="1" data-item-label="OPS1">
<td>OPS1 - Supplier1</td>
</tr>
</tbody>
</table>

My selenium code :

// supplier ops, i find and type data into the input
WebElement eSupplier = driver.findElement(By.id("supplier:supplierOps_input"));
eSupplier.sendKeys("OPS1");
sleep(5); // wait the suggestbox

// i find the suggestbox
WebElement eSupplierSuggest = driver.findElement(By.xpath("//div[@id='supplier:supplierOps_panel']/table/tbody/tr"));
eSupplierSuggest.click();
sleep(5); // wait the refresh for the next field supplierAddress

My xpath and everything seems ok.

So, the question is : What element ( td, tr, table, ...) i need to catch/select and what method (driver.click(), sendKeys(), ...) do i need to use to validate the suggestBox?

EDIT :

The suggestbox hasn't the focus when it appreas to validate. So i'm searching to set the focus on it and try a sendKeys(Keys_ENTER). Set focus on WebElement?

EDIT2 :

Some news guys, I'm going to try to solve it with Arquillian Graphene. It's a framework that enforces tester to write Ajax-enabled and reusable tests and test abstractions,

Links : Introduction to Graphene - Graphene 2.0.0.Alpha3 Released - JBoss Community Graphene2 - Jquery Selector

Community
  • 1
  • 1
e1che
  • 1,241
  • 1
  • 17
  • 34

2 Answers2

0

Try using cssSelector for the autosuggestion click as shown below and let me know if you are still facing the issue.

 // supplier ops, i find and type data into the input
    WebElement eSupplier = driver.findElement(By.id("supplier:supplierOps_input"));
    eSupplier.sendKeys("OPS1");
    sleep(5); // wait the suggestbox

    // i find the suggestbox
    WebElement eSupplierSuggest = driver.findElement(By.cssSelector("css path of that specific value in the auto suggestion box"));
    eSupplierSuggest.click();
    sleep(5); // wait the refresh for the next field supplierAddress
HemChe
  • 2,249
  • 1
  • 21
  • 33
  • Still the same, i can get the element, but i can't interact with. – e1che Apr 03 '13 at 13:09
  • The above approach is working for me when i am testing the google search autocomplete options. Let me know the web application you are testing upon if it is not confidential, so that i can debug the issue. – HemChe Apr 03 '13 at 13:19
  • Mine is pretty diffretent than the google autocomplete. Like there is a field who hide another field etc.. It's harder than i though... but if i get the solution i'll post it here. =) – e1che Apr 03 '13 at 13:50
0

Instead of clicking on the suggestbox, you can locate the suggestbox, then extract the text of the suggest box. Assert that it includes the text you typed in.

Nora
  • 1,432
  • 8
  • 9
  • Sure i can do like that, but i can't validate my choice and if i can't, my ajax don't refresh and i can't enter the address, that's why i use Arquillian Graphene =) – e1che Apr 18 '13 at 06:17