Bear markets like the one the Nasdaq Composite and the S&P 500 have been in since March and June of 2022, respectively, make for a harsh investing environment. But for those who invest with a long-term mindset and don't mind some short-term volatility, bear markets can present some excellent buying opportunities.

What investors need to look for are companies that provide crucial infrastructure for society and their steady businesses can make them an excellent source of returns -- in other words, industry leaders. Granted, many of these types of stocks can be cyclical and their performance is often tied to the broader economy. So, they may struggle a bit during economic slowdowns, but they also tend to bounce back quickly once the economy starts to right itself.

Long-term investors might want to get in on these three industry-leading stocks before the bear market is over.

1. Automatic Data Processing helps businesses outsource essential functions

Automatic Data Processing (ADP -0.35%), better known as ADP, tends to fly under many investors' radars because its business, while crucial, isn't terribly exciting. When companies look to outsource business functions, they frequently turn to ADP. ADP provides companies with human capital management (HCM) solutions, handling things from human resources to payroll and time tracking.

Its scale is phenomenal, with nearly 1 million clients worldwide. It also processes payroll for 39 million workers globally across 140 countries and territories. Its reach in the U.S. is vast, and it processes payroll for one out of every six workers in the U.S. Its secret to success is its technology platform and wide-ranging knowledge of regulations across various regions worldwide. 

You may be concerned about a potential recession. After all, a recent Bloomberg survey revealed that 81% of economists think we'll enter a recession in the next two years. An uptick in unemployment will surely hurt it, right? Not quite.

During a contraction, companies seek out ways to lower their costs. One way they can do that is by outsourcing business functions to ADP. That's exactly what happened during the Great Recession in 2007-09. During this time, ADP grew its revenue and earnings per share and provided investors with a solid defensive stock during a deep market contraction.

The company manages its capital well, has raised its dividend for 48 consecutive years, and its returns have outpaced the market for decades -- which is why this steady business deserves a spot in your portfolio before the bear market ends.

2. Deere provides essential machinery for our most important industries

Deere (DE -0.87%) provides machinery to the agriculture and construction industry, including tractors, harvesters, excavators, and more. It's building on its leading position in the industry with its Smart Industrial operating model. This model helps it focus on strengthening its technology to help farmers increase efficiency, boost yields, lower input costs, and ease labor constraints.

Deere has had a couple of tailwinds working in its favor. For one, the war in Ukraine led to higher commodity prices which led to higher profits for those in the agriculture industry. Deere benefits as farmers invest more in their equipment to meet increased demand. The company has been able to hike prices, and its margins have expanded as a result.

Another tailwind is spending from the Infrastructure Investment and Jobs Act. The law allocates $1.2 trillion to build roads, bridges, public transport, and airports, which will require machinery that Deere can provide. Deere's position as a leading provider of machinery and its strong backlog of orders makes it another solid investment before the bear market is over.

3. Generac stock is beginning to look like a bargain

Generac (GNRC -0.22%) provides generators for businesses and households -- and holds a 75% market share of home generators. Its long-term growth is stellar, but Generac has struggled mightily in the last year and was one of the worst-performing stocks in the S&P 500 last year.

It's not that the business was terrible; it did pull forward demand and achieve incredible growth in 2021. In 2021, sales were up 50%, while net income surged 57%. One driver of this growth was power outages in Texas, which led to a surge in demand for generators. Last year sales slowed down; through the first three quarters of last year, sales were up 32% while net income plunged 19%. 

Generac stock got punished for cutting its guided revenue for the year nearly in half, and the valuation dropped as a result. Not only that, but one of its biggest customers declared bankruptcy, leaving it with an $18 million bad debt expense. Since peaking in November 2021, its shares have lost nearly 79%. For prospective investors, the sell-off has brought down its valuation significantly and makes it an intriguing buy. It currently trades at a price-to-earnings ratio (P/E) of just 16.9 -- the lowest level in years.

GNRC PE Ratio Chart.

GNRC PE Ratio data by YCharts.

Generac stock got ahead of itself, but the underlying business is still solid. While a potential slowdown could hurt it in the short term, it is a top provider of generators for homes. It has also expanded into solar, battery storage, and energy management systems -- and its solid stock to buy at a reasonable price before the bear market ends.