June 13, 2016

Handling OnChange events using Selenium webdriver and Java script

In this post I will discuss about onchange events.

What is onchange event?
The onchange event occurs when the value of an element has been changed.
For radiobuttons and checkboxes, the onchange event occurs when the checked state has been changed.

onChange specifies script code to run when the data in the input field changes. The onChange event is triggered when the contents of the field changes.

In this example if you type some thing in Quantity filed and click on anywhere on the page it will automatically update Total.








We can handle onchange events in different ways.

1. After entering quantity we can simulate clicking TAB button. But this is approach will not work always.

2. By using Java script we can trigger onchange event.


Using Java script to trigger onchange event...


((JavascriptExecutor)driver).executeScript("arguments[0].onchange()", driver.findElement(By.name("vn_qty")));

Below is the sample script.










31 comments:

  1. Excellent and very cool idea and the subject at the top of magnificence and I am happy to this post..Interesting post! Thanks for writing it. What's wrong with this kind of post exactly? It follows your previous guideline for post length as well as clarity..

    Digital marketing company in Chennai

    ReplyDelete
  2. Such a great articles in my carrier, It's wonderful commands like easiest understand words of knowledge in information's.

    ccna training in chennai Adyar

    ReplyDelete
  3. Thank you for your post. This was really an appreciating one. You done a good job. Keep on blogging like this unique information with us.

    Best Seo Services in Chennai

    ReplyDelete
  4. Nice article about Handling OnChange events using Selenium webdriver and Java script.People willing to get the indepth knowledge in getting framework such as TestNG,jenkins,Maven and POM should get properly get Online selenium training in chennai

    ReplyDelete
  5. I learnt how to use selenium web driver & java script.So now it was easy to handle.It was easy to understand me.Thank for sharing that useful information.Keep in blogging.. Selenium Training in Chennai
    Hadoop Training in Chennai
    Dot Net Training in Chennai
    Android Training in Chennai

    ReplyDelete
  6. Dear, I like all your post. Everything looks so sweet, I admire this kind of life and the best wishes for you. Hope that we can communicate with each other. By the way, anybody want to boost app ranking ? This one is useful.

    ReplyDelete
  7. Amazing & Great informative blog,it gives very useful practical information to developer like me. Besides that Wisen has established as Best Java Online Training from India . or learn thru Online Training mode Hibernate Online Training . Nowadays Hibernate ORM has tons of job opportunities on various vertical industry. or learn thru JavaScript Online Training from India. Nowadays even JavaScript has tons of job opportunities on various vertical industry.

    ReplyDelete
  8. Hats off to your presence of mind..I really enjoyed reading your blog. I really appreciate your information which you shared with us.
    ME/M.Tech Project Center in Chennai | ME/M.Tech Project Center in Velachery

    ReplyDelete
  9. Very happy to see this blog. Gives a wonderful information with coded explanaion. Thank you for this blog. very useful to me.
    Java Training Center in Chennai | Best J2EE Training Center in Chennai | No.1 Java Training Institution in Velachery | Core Java Training in Chennai

    ReplyDelete
  10. It is really amazing...Thanks for sharing....Provide more useful information..Embedded Project Center in Chennai | Embedded Project Center in Velachery

    ReplyDelete
  11. I found some useful information in your blog.Thanks for sharing such a wonderful article...
    Best Mobile Computing Project Center in Chennai | Mobile Computing Project Center in Velachery

    ReplyDelete
  12. I have found a lot of interesting information here. It is really a good post.
    IEEE Project Center in Chennai | IEEE Project Center in Velachery

    ReplyDelete