RUVIDEO
Поделитесь видео 🙏

✔ How To Use Selenium Locators To Find WebElements | (Video 41)

A WebElement is anything you see on a web page such buttons, text fields, links, etc.
There are 8 Selenium Locators that help us find WebElements. In alphabetical order, the Selenium Locators are
1. className
2. cssSelector
3. id
4. linkText
5. name
6. partialLinkText
7. tagName
8. xpath

This video shows how to use 6 of the 8 Selenium Locators. A separate video will demo cssSelector and xpath.

► Download Transcript, Presentation, and Code https://www.rexjones2.com/select-webelements-using-selenium/
► View/Download Transcript, Presentation, and Code via GitHub https://github.com/RexJonesII/Selenium4Beginners

All Selenium Locators via Free Selenium Book (pages 54 - 108)
► Free Selenium PDF Book: https://www.rexjones2.com/book-selenium-4-beginners/
► Free Java PDF Book: https://www.rexjones2.com/book-part-1-core-java/
► All Paperback & eBooks: http://tinyurl.com/Rex-Allen-Jones-Books

► Java PDF Book: http://tinyurl.com/Part-1-Java-4-Selenium
► All Paperback & eBooks: http://tinyurl.com/Rex-Allen-Jones-Books

► View All Videos On LinkedIn https://www.linkedin.com/company/28599523/admin/
► View All Videos On YouTube https://www.youtube.com/channel/UCBU_TzaPsDXXeQ3ItUYKaJg/videos
► View All Videos On Facebook https://www.facebook.com/pg/Selenium-4-Beginners-2051994988170815/videos/?ref=page_internal

► Transcript
Hello and Welcome To Selenium 4 Beginners. We are going to discuss How To Use Selenium Locators To Find WebElements. The Transcript, Presentation, and Code will be available on github at RexJonesII/Selenium4Beginners and https://tinyurl.com/SeleniumLocatorsForWebElements.

Before checking out How To Use A Selenium Locator To Find A WebElement, let’s look at the Selenium Locators then at the end we are going to look at the rankings for the Selenium Locators.

In alphabetical order, the 8 Selenium Locators are className, cssSelector, id, linkText, name, partialLinkText, tagName, and xpath. Now, let’s look at the Selenium Locators that help us find WebElements.

I believe finding a WebElement is the most important aspect of automation. Why? because we are unable to perform any action on a WebElement until we first find the WebElement.

I have already created an instance of WebDriver, a setup method to load OrangeHRM, and our Test Method called demoSeleniumLocators. Recall from the previous video, I mentioned id, name, and class are the key attributes for finding WebElements. Therefore, I will start with id which is a unique identifier for an element. We write driver.findElement By then the dot operator. Here’s a list of all 8 Selenium Locators, select id, (pause) and the parameter is the value of id attribute. Let’s go to the AUT and find the value of id by inspecting username.

The value is txtUsername. Copy the value and paste the value. WebElement username = We are not going to perform actions on the WebElement but only find the WebElement. As a result, I will demonstrate finding the WebElement by highlighting each WebElement. Highlighter.highlightElement pass in the driver and pass in username as the WebElement.

This is a static highlighter method so I can call it directly from the utility package. The background will be red with a black border. Highlighter methods are good for demos because it can slow down execution. This execution will slow down for 1 second due to Thread.sleep 1000. Let’s run. Did you see Username highlight red? That shows we successfully found Username. We are going to do that for each WebElement.
driver.findElement By dot name and the parameter is the value of name attribute

Next, is the Password field. The name attribute has a value of txtPassword. Copy and Paste the value. WebElement password = Highlighter.highlightElement pass in the driver and password. Let’s run again then see username and password highlight red.
driver.findElement By dot className and the description shows Find elements based on the value of the class attribute. Inspect button. The class attribute has a value of button. Copy and Paste the value. WebElement buttonLogin = Highlighter.highlightElement pass in the driver and buttonLogin. Let’s Run. We saw all 3 WebElements show a red background.

The next 2 Selenium Locators help find links on a web page: linkText and partialLinkText driver.findElement By dot linkText and parameter is the exact text to match against
driver.findElement By dot partialLinkText finds part of the text.
Let’s use Forgot your password for linkText and OrangeHRM, Inc for partialLinkText. Inspect both WebElements. Here’s the text for Forgot your password and OrangeHRM. WebElement linkForgotPassword = Highlighter.highlightElement pass in driver and linkForgotPassword

The value for Partial Link Text will be OrangeHRM. WebElement linkOrangeHRM = Highlighter.highlightElement pass in driver and linkOrangeHRM. Let’s scroll down the page

#SeleniumTraining #SeleniumAutomation #BeginnerSeleniumTutorials #SeleniumWebDriver

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «✔ How To Use Selenium Locators To Find WebElements | (Video 41)», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.