4

I am having this screen where i try to hover it
enter image description here

after hovering the screen becomes drop down

enter image description here

So i am not able to click on the screen using selenium webdriver.

<td align="left" style="vertical-align: top;">
<div id="gwt-debug-ddPolicy" class="relativePositionNegative12">
<table cellspacing="0" cellpadding="0" class="clickable GP432FWBBU">
 <tbody>
  <tr>
   <td align="left" style="vertical-align: top;">
     <div class="GP432FWBOT GP432FWBDU GP432FWBAU GP432FWBDD" aria-hidden="false" id="gwt-debug-ddPolicy-label" style="">linda</div>
    </td>
   <td align="left" style="vertical-align: top;">
        <select class="GP432FWBOT GP432FWBMT GP432FWBAU" style="display: none;" aria-hidden="true" id="ddPolicy">
           <option value="linda">linda</option>
           <option value="Gaurav">Gaurav</option>
           <option value="*Aung">*Aung</option>
           <option value="Aakash">Aakash</option>
        </select>
    </td>
   <td align="left" style="vertical-align: top;">
   </td>
   </tr>
 </tbody>
</table>
</div>
</td>

I am getting error for other element get position.

  • share your code and error message. – abhijeet kanade Jul 6 '16 at 14:20
  • org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (880, 219). Other element would receive the click: <div class="GP432FWBFT"></div> (Session info: chrome=51.0.2704.103) (Driver info: chromedriver=2.22.397933 – Gaurav Jul 7 '16 at 11:01
  • 1
    I won´t post this as an answer since it's a pretty dirty solution but it seems that the "aria-hidden" attribute controls if the select is shown or not, so you could go with 'JavascriptExecutor JSE =(JavascriptExecutor) driver; JSE.executeScript("document.getElementsByClassName('GP432FWBOT GP432FWBMT GP432FWBAU'[0].setAttribute('aria-hidden', 'false')");' This way, if I got the HTML right, it should show the select box and you can let the WebDriver look for it. – Daniel Jul 8 '16 at 12:56
2

I haven't found a way to do a 'mouse over' option but you can use Action Chains to achieve this.

Actions action = new Actions(webdriver);
WebElement we = webdriver.findElement(By.xpath("expression"));
action.moveToElement(we).moveToElement(webdriver.findElement(By.xpath("expression"))).click().build().perform();
3

Try sending an empty key to the element in order to focus on it as well as set get visible over hidden property. For example:

hidden_element.send_keys "" // This will make element visible first.
hidden_element.click() // Pretty simple job when element is visible.
1

According to your question use ExplicitWait command, this is useful in finding the elements until it gets enables in webpages. It will wait until you get desired element in webpage as:

WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.textToBePresentInElement(By.xpath("xpath expression")

You can find real time examples in this website.

0
        webDriver.findElement(By.cssSelector("div#gwt-debug-ddPolicy")).click();

        JavascriptExecutor executor= (JavascriptExecutor)webDriver;
        executor.executeScript("document.getElementById('ddPolicy').style.display='block';");
        Select select1 = new Select(webDriver.findElement(By.id("ddPolicy")));
        select1.selectByVisibleText("Gaurav");

Code worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.