Skip to main content

Selenium - Drag and Drop Operation


The inbuilt dragAndDrop function provided by selenium RC classes will do the expected operation well easily. Some times its difficult to do drag and drop operations like drop on particular element, etc. Here is the approach.


1. Drag an element to drop on to another element:
  1. driver.get("myURL");
  2. var from = driver.findElement(By.xpath("fromElement"));
  3. var to = driver.findElement(By.xpath("toElement"));
  4. new Actions(driver).dragAndDrop(from, to).build().perform();

2. Drag an element to an offset:
  1. driver.get("myURL");
  2. var dragElement = browser.findElement(By.id("ElementToDrag"));
  3. new Actions(driver).dragAndDropBy(dragElement , 20010).build().perform();


Comments

  1. I actually enjoyed reading through this posting.Many thanks.


    Selenium Training in Chennai

    ReplyDelete
  2. Hey, nice site you have here! Keep up the excellent work!
    Selenium Training in Chennai

    ReplyDelete
  3. Hey, nice site you have here! Selenium Training in Chennai Keep up the excellent work!

    ReplyDelete
  4. Your comment is very good share it.
    http://www.way2automation.com/selenium_tutorial/selenium-training-institute-rc-webdriver-delhi-ncr.html

    ReplyDelete
  5. Java is one of the popular technologies with improved job opportunity for hopeful professionals. Java Course in Chennai helps you to study this technology in details.If you are looking for best Java Training Institutes in Chennai reach Fita academy.

    ReplyDelete
  6. The information you posted here is useful to make my career better. Thanks for sharing such a informative post. keep updates...

    Regards..
    Salesforce Training in Chennai

    ReplyDelete
  7. Thanks for sharing this information. Salesforce is a cloud based CRM. Nowadays most of the multinational companies used this CRM for managing their customers. To know more details call 9841746595.

    Regards..
    Salesforce Training

    ReplyDelete
  8. Thanks for sharing this information. SEO is one of the digital marketing techniques which is used to increase website traffic and organic search results. If anyone wants to get SEO Course Chennai visit FITA Academy located at Chennai.

    ReplyDelete
  9. Really awesome blog. Software testing is a method of executing the application or program with the intent of searching the software errors. Software Testing Course in Chennai offering this course at reasonable cost.

    ReplyDelete
  10. Excellent information. HTML5 is a markup language used for designing responsive website and it is also used for structuring and presenting the website content.

    Regards.
    HTML5 Training | PHP Course in Chennai

    ReplyDelete
  11. I get a lot of great information from this blog. Thank you for your sharing this informative blog. Just now I have completed hadoop certification course at a leading academy. If you are interested to learn Hadoop Course in Chennai visit FITA IT training and placement academy.

    ReplyDelete
  12. Hi, Your blog is really very informative and useful for me. Thanks for sharing this valuable blog.
    Regards..
    Unix Training Institutes in Chennai

    ReplyDelete
  13. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  14. Great efforts put it to find the list of articles useful for Selenium, Definitely will share the same to other forums.
    We are also one of the best sources to learn Selnium -Selenium training in Chennai |Best Selenium training institute in Chennai

    ReplyDelete

Post a Comment

Popular posts from this blog

QTP - Object Identification - Prerequesties

While starting a new project or proof of concept or after new QTP installation, we would face the issue in identifying objects as QTP built objects like WinList, WebEdit, etc.; instead everything will be identified as WinObject.

Here are some steps to ensure you did the environment setup RIGHT before start automating.
Did you enabled required Add-ins only while launchingDid you selected "Record >> Record and Run Settings" - This should be based on what type of application you are working with
Windows app - Windows >> Record and run test on any windows applications. Web app - Web >> Record and run test on any open browser.
Did you tried to launch UFT/QTP and then AUT.If its web, ensure browser zoom level set to 100%Try disabling the protected mode in IE for web.Launch UFT and AUT using RUN AS ADMINISTRATORAlso see the Object Identification Methods if you are interested.

Change IE Browser ZOOM settings

Lot of UI automation testers could have faced this problem as we could change the zoom settings while operating manually for our convenience and forgot to reset to 100%.
But our QTP and some other related tools would operate the browser perfectly if browser zoom is 100%. So wee need to change the zoom before start to run the scripts. Its better to have a code snippet in our framework to change this zoom setting right?
Here we go...

1. We can simply change the Registry values before Invoking IE
Function ChangeRegistry Dim objShell Set objShell = CreateObject("WScript.Shell")  objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor", "100000", "REG_DWORD" Set objShell = Nothing EndFunction This option is very useful. But in real time, lot of customers could have restricted write access to windows registry. So we can try other options.

2. Use IE COM object and Change Settings
Function ChangeIEZoom Dim intZoomLevel, objIE  intZoo…

QTP - Common error messages

Always I am seeing  many of my friends asking for help if any error occurs while running script in QTP without googling for help. How much troubleshooting you guys are doing will directly reflect your knowledge on the tool. I agree, no one knows each and every error occurs in the software. But we can improve our knowledge by googling and doing workarounds...
Whenever the question "How much level you know QTP?" arrows me, always I am comfortable with the answer "below 10%". But after answered, my mind will have an inner thought like, What are the things I have to learn to fulfill the answer I have told because I never used lot of features in QTP.

Here I am listing out some of the errors, situations and what might be the original issue things etc. I hope this will give you some ideas to improve your debug ability and to solve your errors. Kindly correct me If I am wrong in any point.

Type mismatch:
- Mostly doing operations with different data types without doing type co…