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

Getting started with selenium

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Selenium Introduction

1. Element positioning

Locate elements by id e.g. WebElement ele = By.id ("idName");

Location of elements by Name: WebElement ele = By.Name("name");

2. Multi-language switch:

ChromeOptions op=new ChromeOptions(); //Select browser

op.addArguments("--lang=en-US"); //Select language

WebDriver =new ChromeDriver(op); //Open browser

3.driver.get(url); //Open link

Thread. sleep (2000); //delay 2000 ms to execute next step

5.try{

Thread.sleep(1000);//wait 1000 ms

}catch(InterruptedException e){

e.printStackTrace();//print error message when try error

}

There are eight ways to locate selenium.

By.id () Locate by id

By.name () Locate by name

By.xpath() Locate by xpath

By.className() Locate by className

By.cssSelector() Positioning via CSS

By.linkText() by linkText

By.tagName() by tagName

By.partialLinkText() By matching to the partialLinkText

7.driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

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