Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Some methods of WebDriver that we are easy to overlook

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

1. Maximize browser

Driver.manage (). Window (). Maximize ()

two。 Set a fixed browser size

This method is very good for pc and mobile compatible pages designed with CSS3 and HTML5, and the control of pc version and mobile version is realized by switching window size.

Driver.manage (). Window (). SetSize (new Dimension (800,600))

3. Browser refresh

Driver.navigate () .refresh ()

4. Browser forward

Driver.navigate () .forward ()

5. Browser fallback

Driver.navigate () .back ()

6.cookie Settin

Driver.manage () .addCookie (new Cookie (name, value)

Driver.manage () .getCookies ()

Driver.manage () .deleteCookie (new Cookie (name, value)

7. When Firefox is not installed in the default path, set the firefox path before starting Firefox driver

For example, Firefox is installed in D:\ Program Files\ Mozilla firefox

System.setProperty ("webdriver.firefox.bin", "D:/Program Files/Mozilla firefox/firefox.exe")

By the same token, because IE and Chrome have their own driver server and need to set their own paths.

For example, chromedirver.exe is locally located at D:\ WebDriver\ chromedriver.exe

System.setProperty ("webdriver.chrome.driver", "D:/WebDriver/chromedriver.exe")

IEDriverServer.exe is locally located at D:\ WebDriver\ IEDriverServer.exe

System.setProperty ("webdriver.ie.driver", "D:/WebDriver/IEDriverServer.exe")

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report