How to count words in notepad File using Selenium

0 votes
How can i count words in notepad file like count words, characters line using selenium.

Need some small program to perform notepad operations.
Aug 6 in Selenium by anonymous
210 views

1 answer to this question.

0 votes

To perform character count.

String fPath="D:/MyTextFile.txt";
int fileCharactersCount=Files.readAllBytes(new File(fPath).toPath() ).length;
System.out.println("fileCharactersCount: "+fileCharactersCount);

To perform word count in text or notepad file.

String fPath="D:/MyTextFile.txt";
int fileWordCount=0;
for (String line : Files.readAllLines(new File(fPath).toPath())) 
{
      line.replace("\t", " ");
      fileWordCount+=new StringTokenizer(line, " ").countTokens();
}
System.out.println("fileWordCount: "+fileWordCount);

For more details and notepad related operations use below link.

  1. Jar file for notepad operation
  2. Notepad related function create and update.
answered Aug 7 by neerajv
• 170 points
It is working.. thank you.
@neerajv, your automation script works fine for me. Thanks

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,430 points
2,441 views
0 votes
1 answer

How to scroll the Page up or down in Selenium WebDriver? (using java)

Its pretty simple. Check out the below ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,430 points
8,985 views
0 votes
1 answer

How to handle Pop-up in Selenium WebDriver using Java

Actually, its pretty simple. Use this code ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,430 points
5,324 views
0 votes
1 answer

How to upload a resume to a website using selenium in python?

Use this code, this will help you: from ...READ MORE

answered Apr 20, 2018 in Selenium by Vardy
• 2,270 points
1,111 views
+9 votes
15 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,270 points
76,664 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,430 points
1,190 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,510 points
1,274 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,510 points
1,032 views