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.










72 comments:

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. It is really amazing...Thanks for sharing....Provide more useful information..Embedded Project Center in Chennai | Embedded Project Center in Velachery

    ReplyDelete
  7. 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
  8. 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
  9. Well Said, you have provided the right info that will be beneficial to somebody at all time. Thanks for sharing your valuable Ideas to our vision. Keep it up. Business Administration Summer Camp in Velachery | Business Administration Summer Classes in Chennai | Business Administration Summer courses in Taramani

    ReplyDelete
  10. Amazing Article, thank you!. I am very glad to read your informative & practical blog. Kindly keep updating your blog.
    Excellent Summer Courses for Business Administration in Chennai | Perfect Summer Courses in Guindy

    ReplyDelete
  11. Great post! I am actually getting ready to across this information, It's very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well..
    Summer Training for Graphic Designing in Chennai | Summer Training for Graphic Designing in Velachery

    ReplyDelete
  12. Truly a very good article on how to handle the future technology,thanks for taking the time to discuss this, I feel happy about and I love learning more about this topic.
    Good Summer Courses for Hardware and Networking in Chennai | Perfect Vacation Courses in Chennai

    ReplyDelete
  13. It is most knowledgeable information like this.I will read this article it is very easy to learn this blog.
    Summer Camp for Kids in Chennai | Summer courses in Shozhinganallur | Summer classes in Chennai

    ReplyDelete
  14. Awesome list, just starting a blog and this is going to be a massive help. Thank you!
    Best Multimedia Vacation Course in Chennai | No.1 Summer Courses in Porur

    ReplyDelete
  15. Really its a very good article, thanks for taking the time to discuss this, I feel happy about and I love learning more about this topic. Graphic Designing Summer Courses in Velachery | Graphic Designing Summer Courses in Chennai | Graphic Designing Summer Courses in Taramani

    ReplyDelete
  16. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…
    Software Testing Summer Courses in Adyar | Summer Courses in Velachery | Java Summer Courses in Perungudi

    ReplyDelete
  17. Thanks for this grateful information. all this information is very important to all the users and can be used good at all this process.
    Selenium Summer Courses in Velachery | Web designing summer Classes in Adyar | Android summer Courses in OMR

    ReplyDelete
  18. Great blog.you put Good stuff.All the topics were explained briefly.so quickly understand for me.I am waiting for your next fantastic blog.Thanks for sharing.
    ISTQB Certification Training in Chennai | Java Exam Center in Chennai | Microsoft Dot net Certification in Chennai

    ReplyDelete
  19. Great Blog... The information you shared is very effective for learners I have got some important suggestions from it, Keep Sharing such a nice blog.
    UIPath Exam Center in Chennai | Automation Anywhere Exam Center in Chennai | Blue Prism Exam Center in Chennai

    ReplyDelete
  20. Nice post... Really you are done a wonderful job. Thanks for sharing such wonderful information with us. Please keep on updating..
    Cisco CCNA Certification Center in Chennai | Best Cisco Center in Guindy

    ReplyDelete
  21. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing... Python Certification Training Institute in Chennai | Best Python Center in Taramani

    ReplyDelete
  22. Thank you.. This worked for my usecase..

    ReplyDelete
  23. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting....
    BluePrism Training Institute in Chennai | UIPath Training Institute in Chennai | Automation Anywhere Training Institute in Chennai

    ReplyDelete
  24. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!
    No.1 Microsoft Azure Training Institute in Chennai | No.1 Microsoft Azure Training Institute in Velachery

    ReplyDelete
  25. Tutorial is very great.your sharing content is very interested.Thanks to sharing.keep it.
    Cloud Computing Training Institute in Chennai | Cloud Computing Training Institute in Velachery

    ReplyDelete
  26. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    No.1 Selenium Tools Training institute in Chennai | No.1 Selenium Tools Training institute in Velachery

    ReplyDelete
  27. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting....
    Best RPA Training Institute in Chennai | Best RPA Training Institute in Velachery

    ReplyDelete
  28. I am really happy to found such a helpful and fascinating post that is written in well manner.
    Selenium Training Institute in Chennai | Selenium Training Institute in Velachery

    ReplyDelete


  29. افضل شركة مكافحة حشرات بالخبر افضل شركة مكافحة حشرات بالخبر
    افضل شركة مكافحة حشرات بمكة افضل شركة مكافحة حشرات بمكة
    افضل شركة مكافحة حشرات بالمدينة المنورة افضل شركة مكافحة حشرات بالمدينة المنورة
    افضل شركة مكافحة حشرات بالدمام افضل شركة مكافحة حشرات بالدمام
    افضل شركة مكافحة حشرات بالاحساء افضل شركة مكافحة حشرات بالاحساء

    ReplyDelete
  30. Are you blacklisted? Struggling to get a personal loan? Has your application been DECLINED due to Low Credit Score? Over COMMITTED? Affordability? But you know you can afford this loan. Loans Approved in 4hours, you can email us at opploansLLC@gmail.com

    Names:
    Occupation:
    Loan Amount Needed:
    Loan Duration:
    Your Country:
    Mobile NO:
    Purpose Of Loan:
    Email Address:
    monthly income:
    Sex:
    Age:

    Opportunity Financial, LLC

    ReplyDelete
  31. Robot Framework is an easy to learn and use framework. This article is a theoretical explanation of the Robot Framework Videos and Robot Framework Tutorials. It is very powerful and apt to be an acceptance level test automation framework. It is flexible  Selenium Training Online

    ReplyDelete