Unable to locate locate the webelemnt while running script

92 views
Skip to first unread message

Randeep Singh

unread,
Jan 26, 2021, 11:08:13 AM1/26/21
to Selenium Users

Hi,
Please help me in getting rid of NoSuchElementException while trying to locate the webelement

Tried using Implicit wait , Explicit wait, Thread.sleep
Not working

Though the xpath is correct
Please refer to the screen shots

Thanks,
Randeep
eclipse-workspace - SelniumPrac1_src_test_java_WebSiteAutomate_ActionDrgndDrop.java - Eclipse IDE 1_26_2021 9_34_11 PM.png
Droppable _ jQuery UI - Google Chrome 1_26_2021 9_34_30 PM.png

Pankaj Shrikanth Yogi

unread,
Jan 26, 2021, 11:31:04 AM1/26/21
to seleniu...@googlegroups.com
The only thing which you are missing is before drag n drop action you need to switch the frame.
Regards,

Pankaj Yogi



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/078c7b77-897d-4e14-9e68-9d5e8dadb65cn%40googlegroups.com.

Deepika B

unread,
Jan 26, 2021, 12:08:35 PM1/26/21
to seleniu...@googlegroups.com

Randeep Singh

unread,
Jan 26, 2021, 12:09:21 PM1/26/21
to Selenium Users

Hi,
I tried that as well,please see this code and let me know have i missed something
public class ActionDrgndDrop {
    static WebDriver wd;
    static WebDriverWait wt=null;
    public static void main(String[] args) {
       
        WebDriverManager.chromedriver().setup();
        wd=new ChromeDriver();
        wd.get("https://jqueryui.com/droppable/");
       
        wd.manage().window().maximize();
        wd.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
        //wd.switchTo().frame(wd.findElement(By.xpath("//iframe[@class='demo-frame']")));   
       
        wd.switchTo().frame(wd.findElement(By.className("demo-frame")));
      WebElement w1=wd.findElement(By.xpath("//div[@id='draggable']"));
               
    WebElement w2=wd.findElement(By.xpath("//div[@id='droppable']"));
    Actions a1=new Actions(wd);
    //a1.clickAndHold(w1).perform();
a1.dragAndDrop(w1, w2).build().perform();

//    //System.out.println(w2.getAttribute("class"));
    }

Exception in thread "main" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: move target out of bounds
  (Session info: chrome=88.0.4324.104)

Deepika B

unread,
Jan 26, 2021, 12:26:21 PM1/26/21
to seleniu...@googlegroups.com
I guess classname will not workout if class attribute value is mutliword..please try with alternative to locate.

If u r working only with one method from actions class then no need of using build() bt this id nt an issue just am suggesting

Randeep Singh

unread,
Jan 26, 2021, 9:41:48 PM1/26/21
to seleniu...@googlegroups.com
Classname attribute is working as. I am able to print out the additional attribute by Webelent w1 and w2.
Though I have also tried passing xpath while switching to frame.

But as and when I try using DragandDrop of Actions, the exception occurs.
I made a seperate program to check the mouse hover functionality by using movetoelement(Webelemnt), it worked fine for me.

Please help me getting into the root cause of this issue.

Randeep

Reply all
Reply to author
Forward
0 new messages