Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

How To: Table Data In Selenium (2 Min) Using Python, PyTest & PyCharm

Автор: Gokce DB

Загружено: 2022-04-10

Просмотров: 199

Описание:

In this tutorial, you'll learn how to extract table data in Selenium using Python, PyTest and PyCharm.

—
Facebook:   / gokcedbsql  
—
Video Transcript:
—
Hi guys, this is Abhi from Gokce DB. In this video, you are going to learn how to extract data from a web table in Selenium using Python.

Let’s start by looking at the past scenario on Mozilla dot org. I want to go to this specific URL and read the items sold in the August two thousand sixteen table.

More specifically, I want to assert whether the total item sold in Amsterdam is equal to three fifteen or not. Now, let’s look at the past directory.

I have a contest dot py file where I’m defining the driver fixture function to initialize the Chrome web driver. In the past file, I’m passing the driver fixture function as the first argument to my past function.

On line five, I’m using the driver dot get method to go to the Mozilla dot org URL. On line seven, I’m reading the text of the sixth row of the item sold on the table.

Line twelve, I’m splitting the table row with this space delimiter and looping through the individual item. Within the four loops, if the item is after type int I add it to the total variable.

Else, I ignore the item. Finally, on line nineteen, I’m asserting whether the total is equal to three fifteen or not.

Now, let’s run this program to see what the output looks like. As you can see, since the total came out to three hundred fifteen our task passed.

Let’s see what happens if I change the total to three hundred twenty and re-run the program. This time our task failed as expected.

Finally, to export the past results in an HTML format click on the EXPORT TEST RESULTS button. There you have it.

Make sure you like, subscribe, and turn on the notification bell. Until next time.

from selenium.webdriver.common.by import By


def test_table_row_sum(driver):
driver.get("https://developer.mozilla.org/en-US/d...")

table_row = driver.find_element(
By.XPATH, '// *[ @ id = "content"] / article / div[7] / div[1] / table / tbody / tr[6]').text

print("Table row text:", table_row)
total = 0
for item in table_row.split(' '):
try:
total += int(item)
except ValueError:
print("Ignoring item", item, "because it's not an int")

print("Sum:", total)
assert total == 315

import pytest
from selenium import webdriver
import os


@pytest.fixture()
def driver():
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
driver = webdriver.Chrome(executable_path=root_dir + '/resources/chromedriver')
Time in seconds driver should wait when searching for an element if it is not
immediately present
driver.implicitly_wait(2)
yield driver
driver.quit()

How To: Table Data In Selenium (2 Min) Using Python, PyTest & PyCharm

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Dictionary Comprehension: 7 Ways To Use In Python (2 Min)

Dictionary Comprehension: 7 Ways To Use In Python (2 Min)

Компания Salesforce признала свою ошибку.

Компания Salesforce признала свою ошибку.

Excel против Power BI против SQL против Python | Сравнение на фондовом рынке

Excel против Power BI против SQL против Python | Сравнение на фондовом рынке

AWS Lambda + ChatGPT API = 🔥

AWS Lambda + ChatGPT API = 🔥

Твоя ПЕРВАЯ НЕЙРОСЕТЬ на Python с нуля! | За 10 минут :3

Твоя ПЕРВАЯ НЕЙРОСЕТЬ на Python с нуля! | За 10 минут :3

Я в опасности

Я в опасности

Анатомия масштабируемого проекта Python (FastAPI)

Анатомия масштабируемого проекта Python (FastAPI)

SAMOBÓJ I 106. GOL LEWANDOWSKIEGO W LIDZE MISTRZÓW! | SLAVIA - FC BARCELONA, SKRÓT MECZU

SAMOBÓJ I 106. GOL LEWANDOWSKIEGO W LIDZE MISTRZÓW! | SLAVIA - FC BARCELONA, SKRÓT MECZU

Твой голос на английском за 10 минут: CapCut + MiniMax (Бесплатно)

Твой голос на английском за 10 минут: CapCut + MiniMax (Бесплатно)

Inauguracja Rady Pokoju. Trump podziękował Nawrockiemu

Inauguracja Rady Pokoju. Trump podziękował Nawrockiemu

it only took 2 characters

it only took 2 characters

RAG + Langchain Python Project: Easy AI/Chat For Your Docs

RAG + Langchain Python Project: Easy AI/Chat For Your Docs

1С: УНФ. Проведение документов

1С: УНФ. Проведение документов

Python  - Полный Курс по Python [15 ЧАСОВ]

Python - Полный Курс по Python [15 ЧАСОВ]

Можно ли установить диск (SSD или HDD) с Windows 11 на новый комп?

Можно ли установить диск (SSD или HDD) с Windows 11 на новый комп?

Docker за 20 минут

Docker за 20 минут

Kowalski wszedł na mównicę i zaczął wymieniać nazwiska posłów! O co chodzi? ZOBACZ!

Kowalski wszedł na mównicę i zaczął wymieniać nazwiska posłów! O co chodzi? ZOBACZ!

AWS Automation with Python Boto3

AWS Automation with Python Boto3

What Is AWS EC2? Instance Types, Pricing, And Basics Explained

What Is AWS EC2? Instance Types, Pricing, And Basics Explained

NI в Жизни, Бизнесе и Науке | Топ Инновационных Компаний и LabVIEW | Database Tool | Insert Record

NI в Жизни, Бизнесе и Науке | Топ Инновационных Компаний и LabVIEW | Database Tool | Insert Record

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com