tag:blogger.com,1999:blog-543267854941927967.post2986600632493723350..comments2024-02-24T15:40:28.077+05:30Comments on My Thoughts: Handling "drag and drop" actions using WebDriver(Selenium 2)Unknownnoreply@blogger.comBlogger28125tag:blogger.com,1999:blog-543267854941927967.post-75685429601973522192014-01-21T17:16:17.365+05:302014-01-21T17:16:17.365+05:30Hi Vamshi, I want to drag and drop in a pop up.
He...Hi Vamshi, I want to drag and drop in a pop up.<br />Here is the html code of that:<br />Please let me know as soon as possible.Dinesh babunoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-15591346947027050592013-11-01T16:22:16.800+05:302013-11-01T16:22:16.800+05:30I must say your blog pretty much good and well org...I must say your blog pretty much good and well organized :)Vamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-23918987151627590692013-11-01T16:14:43.413+05:302013-11-01T16:14:43.413+05:30you have explained it to the very basics. Thank yo...you have explained it to the very basics. Thank you. it worked. :) if you have time check up on my blog about #Selenium. i would love to see ya comments. http://anjiztechshare.blogspot.com/Anjalanoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-66920271040987387702013-10-01T11:35:58.331+05:302013-10-01T11:35:58.331+05:30Thanks Chaitanya. I really appreciate it :)
Wish ...Thanks Chaitanya. I really appreciate it :) <br />Wish you luckVamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-56088425177419642902013-10-01T11:31:59.499+05:302013-10-01T11:31:59.499+05:30Hi Vamshi,Good Morning.I would like to Thank You f...Hi Vamshi,Good Morning.I would like to Thank You for this wonderful site that you have given us who are learning Selenium.Please continue with your Great Work.Thanks Again.~ChaitanyaMadiraju Krishna Chaitanyanoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-81805279048368379092013-10-01T10:06:43.216+05:302013-10-01T10:06:43.216+05:30Hi Vamsi,Good Morning.Thanks a LOT for creating th...Hi Vamsi,Good Morning.Thanks a LOT for creating this WebSite for us who are learners of selenium.Please keep Posting the articles/posts that you learn/come across.All the Best.Thanks Again.~chaitanyaMadiraju Krishna Chaitanyanoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-17659784231610016682013-08-29T18:19:00.343+05:302013-08-29T18:19:00.343+05:30Ya i have tired. Its click on that particular elem...Ya i have tired. Its click on that particular element which i need to drag. But its not dropping. :(sasi kalanoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-20028905860936005262013-08-29T17:58:08.769+05:302013-08-29T17:58:08.769+05:30If you know the frame id then use id itself.
fr...If you know the frame id then use id itself. <br /><br />frame(0) may or may not work because 0 is the index of frame. In your page try to find the frame index of frame you are working on. <br /><br />use the below code to get all iframes in the page <br /><br /><br /><br />driver.get("https://www.facebook.com/googlechrome/app_158587972131"); <br />List totaliFrames=driver.findElements(By.tagName("iframe")); <br />System.out.println("total links "+totaliFrames.size());Vamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-8283352212445772992013-08-29T17:33:37.071+05:302013-08-29T17:33:37.071+05:30Hey,
driver.switchTo().frame(0);
Is this will ...Hey,<br /> driver.switchTo().frame(0);<br /><br />Is this will work with frame?sasi kalanoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-53335946943779634672013-08-29T17:17:34.096+05:302013-08-29T17:17:34.096+05:30Drag and drop should work even in iframes.
Make s...Drag and drop should work even in iframes. <br />Make sure you identify the drag and drop elements correctly with proper id or xpath .Vamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-67225031541025266862013-08-29T17:11:05.389+05:302013-08-29T17:11:05.389+05:30Ya Vamshi your correct its a frame only. How can i...Ya Vamshi your correct its a frame only. How can i drag from one iframe and drop it in another iframe?sasi kalanoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-35043075322669200382013-08-29T16:51:26.753+05:302013-08-29T16:51:26.753+05:30From screen , it looks like the area where you wou...From screen , it looks like the area where you would like to drag an element is inside another frame. {I might be wrong} . If it happens to be inside iframe then make sure you switch to proper iframe before identifing the element. <br /><br />http://www.mythoughts.co.in/2012/05/permission-denied-for-to-get-property.html<br /><br />http://www.mythoughts.co.in/2012/05/getting-total-noof-checkboxestextboxesd.htmlVamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-79758049804837226842013-08-29T16:04:03.086+05:302013-08-29T16:04:03.086+05:30Nope :(
I have attached a screenshot. Let me kno...Nope :( <br /><br />I have attached a screenshot. Let me know if this is helps.sasi kalanoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-8611918139915514032013-08-27T14:19:56.019+05:302013-08-27T14:19:56.019+05:30Do you have the public site url on which you are p...Do you have the public site url on which you are performing this test ?Vamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-32695054902070136282013-08-26T21:09:55.809+05:302013-08-26T21:09:55.809+05:30Can u please tell me what mistake am i doing here....Can u please tell me what mistake am i doing here. Because i coulnt able to drag the element. always i am getting error saying that unable to locate the element.<br /><br />Html element:<br /><br />Which i need to drag the element<br /><br /><br /><br /><br /><br />Name<br /><br /><br /><br /><br /><br />First Name<br /><br /><br /><br />Which i need to drop the element<br /><br />Here is div contains the iFrame<br /><br /><br /><br />Here is my code:<br /><br />driver.switchTo().frame(0); <br /><br /> driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);<br /><br /> /*WebElement dragElement = new FluentWait(driver)<br /><br /> .withTimeout(60,TimeUnit.SECONDS)<br /><br /> .pollingEvery(5,TimeUnit.SECONDS)<br /><br /> .ignoring(NoSuchElementException.class).until(ExpectedConditions.visibilityOfElementLocated(By.xpath(("//*[@id='companyName_pannel']")))); */<br /><br /> WebElement dragElement=driver.findElement(By.xpath("//*[@id='fullName_pannel']"));<br /><br /> /*WebElement dropElement = new FluentWait(driver)<br /><br /> .withTimeout(60,TimeUnit.SECONDS)<br /><br /> .pollingEvery(5,TimeUnit.SECONDS)<br /><br /> .ignoring(NoSuchElementException.class).until(ExpectedConditions.visibilityOfElementLocated(By.xpath(("//*[@id='formcontent']")))); */<br /><br /> WebElement dropElement=driver.findElement(By.xpath("//*[@id='formcontent']")); <br /><br /> Actions builder = new Actions(driver); // Configure the Action <br /><br /> Action dragAndDrop = builder.clickAndHold(dragElement) <br /><br /> .moveToElement(dropElement) <br /><br /> .release(dropElement) <br /><br /> .build(); // Get the action <br /><br /> dragAndDrop.perform(); // Execute the Action <br /><br /> //Thread.sleep(6000);sasi kalanoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-29632115075717377832013-05-29T11:42:37.711+05:302013-05-29T11:42:37.711+05:30Jack,
Can you try by updating your jars?Jack,<br /><br /><br />Can you try by updating your jars?Vamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-73669641047445311332013-05-29T11:39:29.078+05:302013-05-29T11:39:29.078+05:30Hey thanks for the info Nitin :)Hey thanks for the info Nitin :)Vamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-652505262299378632013-05-28T22:21:48.835+05:302013-05-28T22:21:48.835+05:30Hi Vamshi!
I found what the issue is, it's p...Hi Vamshi! <br /><br />I found what the issue is, it's problem with Selenium driver and the firefox version. I have ff of version 21 and Selenium 2.32 doesn't support this action sequence on this version of browser. So on upgrading to 2.33 Selenium server, it works fine.Nitinnoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-74810738028039935022013-05-28T18:20:41.567+05:302013-05-28T18:20:41.567+05:30hi vamshi kurra,
i am getting the same error as...hi vamshi kurra, <br /><br /><br />i am getting the same error as raju got , could let me know why it is occuringjacknoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-81775283565444640102013-05-27T18:35:19.604+05:302013-05-27T18:35:19.604+05:30You can try below html code:
div#n1:active{
b...You can try below html code:<br /><br /><br /><br /><br /><br />div#n1:active{<br />border: 0px solid #000000;<br /><br /><br /> font : normal normal 16px Helvetica ;<br /> color: yellow;<br />}<br /><br /><br /><br /><br /> I have a bike<br><br /> I have a car <br /><br /><br /><br /><br /><br />Here exact scenario i have put. You can check that, when i clickAndHold on checkbox, the color changes to "yellow". When i release it gets back to original.<br /><br /><br />I think this example would be simpler to understand my issue.<br /><br /><br />ThanksNitinnoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-47362512455961488052013-05-27T18:11:18.476+05:302013-05-27T18:11:18.476+05:30Nitin,
Do you have any example site ?Nitin,<br /><br />Do you have any example site ?Vamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-73570636383428661052013-05-27T18:09:35.069+05:302013-05-27T18:09:35.069+05:30Hi Vamshi,
I have one more query related to thi...Hi Vamshi, <br /><br /><br />I have one more query related to this. Suppose their is a focus skin which displays only on clickAndHold(), how do i capture the screenshot of that focus skin before release()? I worked with this above code, but cudn't work out. <br /><br /><br />Any suggestions how to go with this?<br /><br /><br />Thanks<br />NitinNitinnoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-18872836533726158092013-05-26T01:07:50.402+05:302013-05-26T01:07:50.402+05:30Thanks :) it workedThanks :) it workedNitinnoreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-39428918014451035882013-05-25T15:27:32.554+05:302013-05-25T15:27:32.554+05:30You can do this by using two different Actions cla...You can do this by using two different Actions classes. <br /><br />Here is the sample code :<br /><br />WebElement dragElement=driver.findElement(By.id("draggable"));<br />WebElement dropElement=driver.findElement(By.id("droppable"));<br /><br />Actions builder = new Actions(driver); <br />Action dragAndHold= builder.clickAndHold(dragElement)<br /> .build(); <br />dragAndHold.perform();<br /><br />File beforeImage = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); <br />FileUtils.copyFile(beforeImage, new File("C:\\Users\\Public\\Pictures\\Sample Pictures\\beforeimage.png")) ;<br /><br /><br />Actions builder1 = new Actions(driver);<br />Action dragAndDrop = builder1.clickAndHold(dragElement) <br /> .moveToElement(dropElement)<br /> .release(dropElement)<br /> .build(); // Get the action<br />dragAndDrop.perform(); <br /><br /><br />File afterImage = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); <br />FileUtils.copyFile(afterImage, new File("C:\\Users\\Public\\Pictures\\Sample Pictures\\afterimage.png")) ;Vamshi Kurrahttp://www.mythoughts.co.in/noreply@blogger.comtag:blogger.com,1999:blog-543267854941927967.post-13809588252207768152013-05-25T12:57:18.978+05:302013-05-25T12:57:18.978+05:30Hi i have looked into this code and modified as su...Hi i have looked into this code and modified as such that when i clickAndHold() i want a screenshot before release(). I have added a method Screenshot() extending Actions class. Can you suggest will this work. coz wen i do this, the Screenshot() captured is before clickAndHold(). How to do this? Any idea?Nitinnoreply@blogger.com