0

HTML code

<div qxselectable="off" >
<div qxselectable="off" >
<div tabindex="1" qxselectable="off" >
<div tabindex="1" qxselectable="off" >
<div style="overflow: hidden; >Discrepancy Type*</div>
<div class="qx-input-required" tabindex="7" ">    
<input class="qx-abstract-field qx-placeholder-color" >
//On Below button there is one dropdown button on which i want to click but i cannot 
<div class="qx-button" qxselectable="off" >
<div qxselectable="off" qxanonymous="true" ></div>
</div>
</div>
</div>
<div tabindex="1" qxselectable="off" >
</div>
</div>
<div class="qx-outSet" qxse..

Java Code

WebElement element = wd.findElement(By.className("qx-input-required"));
Actions actions = new Actions(wd);
actions.moveToElement(element).click().perform();
wd.findElement(By.xpath(".//*[@id='demindoRoot']/div[3]/div[2]/div[1]/div/div[2]/div[2]/div/div")).click(); // link through which i try to click 
Thread.sleep(1000);

I also tried with below mention code

wd.findElement(By.xpath("//div[@class='qx-button'"));

enter image description here

Error :

Unable to locate element:

ekad
  • 14,436
  • 26
  • 44
  • 46
Dhaval Atri
  • 201
  • 2
  • 6
  • 15

3 Answers3

1
action.moveToElement(element).moveToElement(driver.findElement(By.Xpath(<Your path here>))).click().build().perform();

This performs the action more like a user would. They user first navigates to the menu, opens it, then navigates to the element they wish to click. Check out this question for more details: https://stackoverflow.com/a/17294390/3537915

Community
  • 1
  • 1
Pseudo Sudo
  • 1,402
  • 3
  • 16
  • 34
  • Thanks NATE ....for your sugession but in which path you want me to try ? button on which i want to click or a path of the same pop up window ??/action.moveToElement(element).moveToElement(driver.findElement(By.Xpath())).click().build().perform(); s – Dhaval Atri Sep 14 '16 at 12:42
  • Bcoz the dropdown made using the
    not using
    – Dhaval Atri Sep 14 '16 at 12:45
  • should be the Xpath of the menu item that you are wanting to click. – Pseudo Sudo Sep 14 '16 at 12:48
  • M sorry but found the below mention error Unable to locate element: {"method":"xpath","selector":".//*[@id='demindoRoot']/div[3]/div[2]/div[1]/div/div[2]/div[2]"} For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html....... – Dhaval Atri Sep 14 '16 at 13:01
  • This means your element is not visible at the moment that you are searching for it. – Pseudo Sudo Sep 14 '16 at 13:02
  • Yes... to deal with that I also put thread.sleep(4000) but having the same Error ...... :( – Dhaval Atri Sep 14 '16 at 13:03
  • If you have the same error then your solution obviously did not solve it. Think about why you are getting the error. – Pseudo Sudo Sep 14 '16 at 13:05
0
WebDriverWait wait = new WebDriverWait(d, 10);
    WebElement val = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath()));
    val.click();


    for(int i=0;i<=100;i++)
    {

        String value=val.getText();
        System.out.println("value is = "+value);
        String value1 = "Your dropdown value";
        if(value.equalsIgnoreCase(value1))
        {
            System.out.println("Got your dropdown value ");
            a.sendKeys(Keys.ENTER).build().perform();
            break;
        }
        a.sendKeys(Keys.DOWN,Keys.DOWN).build().perform();
        Thread.sleep(3000);
        a.sendKeys(Keys.ENTER).build().perform();
    }

xpath should be your dropdown box not of your dropdown value.

Ravi Potnuru
  • 191
  • 4
  • 13
0

Basically when we works with anywebapplication which developed using any javascript freamwork at that w cannot get any proper element to interact. We have to work with lots of and . So while selecting any value from dropdown we have to use sendkeys. OR simple type single character and select value from suggestion list. Above two solution works for me .

Thanks -Dhaval

Dhaval Atri
  • 201
  • 2
  • 6
  • 15