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
2,248 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,500 points
8,359 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 6, 2020 in Selenium by Sri
• 3,190 points
18,913 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 6, 2018 in Selenium by nsv999
• 5,500 points
10,558 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
2,883 views
+10 votes
17 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
197,977 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,500 points
13,676 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,190 points
9,144 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,910 points
7,221 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 3, 2020 in Selenium by Sri
• 3,190 points
7,875 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP