Keyboard Operations in Selenium using Actions class




Press any key in the text box!




Press any key in the text box!




Press any key in the text box!


package com.automation.tests;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class ActionsDemoKeyboard {
    ChromeDriver driver;
    
    @Test
    public void actionsDemoKeyboard() throws InterruptedException{
        Actions actions = new Actions(driver);

        WebElement element = driver.findElement(By.xpath("//input[@id='text1']"));
        
        element.click();
        Thread.sleep(4000);
        
        actions.sendKeys(element,"abcd").build().perform();
        
        element = driver.findElement(By.id("text2"));
        
        Thread.sleep(4000);
        actions.sendKeys(Keys.TAB).perform();
        
        Thread.sleep(4000);
        actions.sendKeys("pqrs").build().perform();
        
        element = driver.findElement(By.id("text3"));
        
        Thread.sleep(4000);
        actions.sendKeys(element, "xyz").build().perform();
        
        Thread.sleep(4000);
        actions.sendKeys(element, Keys.BACK_SPACE).build().perform();
        
        Thread.sleep(4000);
        actions.sendKeys(Keys.HOME).perform();
        
        Thread.sleep(5000);
        driver.navigate().refresh();
        Thread.sleep(5000);
    }
    
    @AfterTest
    public void afterActionsDemoKeyboarda() {
        driver.close();
    }
    
    @BeforeTest
    public void beforeActionsDemoKeyboard(){
        driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
        driver.get("http://anish-selenium.blogspot.in/p/keyboard-operations-in-selenium-using.html");
    }
}

55 comments:

  1. A nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.

    Some important links here,

    Selenium Training in Velachery | Best Selenium Training Institute in Chennai

    ReplyDelete
  2. Replies
    1. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

      rpa training in Chennai | rpa training in pune

      rpa training in tambaram | rpa training in sholinganallur

      rpa training in Chennai | rpa training in velachery

      rpa online training | rpa training in bangalore

      Delete
  3. I think you have a long story to share and i am glad after long time finally you cam and shared your experience.
    python online training
    python training in OMR
    python training in tambaram

    ReplyDelete
  4. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    DevOps online Training

    ReplyDelete
  5. Impressive. Your story always bring hope and new energy. Keep up the good work.
    python online training
    python training in OMR
    python training course in chennai

    ReplyDelete
  6. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

    Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies

    Selenium Training in Bangalore | Best Selenium Training in Bangalore

    AWS Training in Bangalore | Amazon Web Services Training in Bangalore

    ReplyDelete
  7. It was a very useful Information.... Thanks for sharing
    Selenium Training in Gurgaon 

    ReplyDelete
  8. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.

    angularjs online training

    apache spark online training

    informatica mdm online training

    devops online training

    aws online training

    ReplyDelete
  9. All the points you described so beautiful. Every time i read your i blog and i am so surprised that how you can write so well.
    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  10. Woah this blog is wonderful i like studying your posts. Keep up the great work! You understand, lots of persons are hunting around for this info, you could help them greatly.
    Microsoft Azure online training
    Selenium online training
    Java online training
    uipath online training
    Python online training

    ReplyDelete
  11. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
    Data Science Training in Chennai | Best Data Science Training in Chennai
    Python Course in Chennai | Best Python Training Course Institutes in Chennai
    RPA Training in Chennai | Best RPA Course Training in Chennai
    Digital Marketing Course in Chennai | Best Digital Marketing Course Training in Chennai

    ReplyDelete
  12. Having read this I thought it was extremely informative. I appreciate you finding the time and effort to put this article together. I once again find myself spending a cloud lot of time both reading and posting comments. But so what, it was still worth it!

    ReplyDelete

  13. Thank you for taking the time and sharing this information with us
    Python Training In Hyderabad

    ReplyDelete
  14. it was a wonderful chance to visit this kind of site and I am happy to know. thank you so much for giving us a chance to have this opportunity.. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points.


    Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery




    ReplyDelete
  15. This is a very interesting web page and I have enjoyed reading many of the articles and posts contained on the website, keep up the good work and hope to read some more interesting content in the future.Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this.
    Data Science Training In Chennai

    Data Science Online Training In Chennai

    Data Science Training In Bangalore

    Data Science Training In Hyderabad

    Data Science Training In Coimbatore

    Data Science Training

    Data Science Online Training


    ReplyDelete
  16. Such a very useful Blog. Very interesting to read this article. I have learn some new information.thanks for sharing. data science courses

    ReplyDelete
  17. Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us. Python Training Institute in Bangalore | Advance Excel+vba Training Institute in Bangalore
    | Selenium Training Institute in Bangalore

    ReplyDelete

  18. Title:
    Best AWS Training in Chennai | Infycle Technologies


    Description:
    Set your career towards Amazon Web Services with Infycle Technologies, the best software training center in Chennai. Infycle Technologies gives the combined and best Big AWS Training in Chennai, along with the 100% hands-on training guided by professional teachers in the field. In addition to this, the interviews for the placement will be guided to the candidates, so that, they can face the interviews without struggles. Apart from all, the candidates will be placed in the top MNC's with a great salary package. To get it all, call 7502633633 and make this happen for your happy life.
    Best traiining in Chennai

    ReplyDelete
  19. Link:
    https://infycletechnologies.com/java-training-in-chennai/

    Keywords:
    If Java Development is a field that you're dreaming of, then we, Infycle, are with you to make your dream into reality. Infycle Technologies offers the best Java Training in Chennai, with various highly demanded software courses such as Big Data, AWS, Python, Hadoop, AWS, etc., in 100% practical training with specialized tutors in the field. Along with that, the pre-interviews will be given for the candidates to face the interviews with complete knowledge. To know more, dial 7502633633 for more.
    best training institute in chennai

    ReplyDelete
  20. Infycle Technologies, the best software training institute in Chennai offers the No.1 Python Certification in Chennai for tech professionals. Apart from the Python Course, other courses such as Oracle, Java, Hadoop, Selenium, Android, and iOS Development, Big Data will also be trained with 100% hands-on training. After the completion of training, the students will be sent for placement interviews in the core MNC's. Dial 7502633633 to get more info and a free demo.

    ReplyDelete
  21. This post is so helpfull and informative.keep updating with more information...
    online marketing
    Definition Of Digital Marketing

    ReplyDelete
  22. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. data scientist course in surat

    ReplyDelete
  23. Hi buddies, it is a great written piece entirely defined, continuing the good work constantly.
    data science coaching in hyderabad

    ReplyDelete