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, 2019 in Selenium by anonymous
685 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, 2019 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
+1 vote
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,520 points
5,600 views
0 votes
2 answers

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

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 5, 2020 in Selenium by Sri
• 3,050 points
15,190 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,520 points
8,341 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,360 points
1,634 views
+11 votes
16 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,360 points
141,466 views
0 votes
2 answers

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,520 points
5,348 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,050 points
6,028 views
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,890 points
3,732 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,050 points
4,547 views