|
1 |
| -<p><strong>Важно! </strong>В этом уроке мы напишем самостоятельно простую реализацию паттерна Page Object. |
2 |
| -А в следующих уроках уже рассмотрим существующие фреймворки и то, |
3 |
| -как они могут облегчить нам жизнь. Сейчас самая главная задача — |
4 |
| -осознать принципы работы. </p> |
| 1 | +<p><strong>Important! </strong>In this lesson, we will write a simple implementation of the Page Object pattern. |
| 2 | +In the following lessons, we will explore existing frameworks and the ways |
| 3 | +they can make our lives easier. Right now, the most crucial task |
| 4 | +is to understand the principles of their work. </p> |
5 | 5 |
|
6 | 6 |
|
7 |
| -<p>Для начала сделаем базовую страницу, от которой будут унаследованы все остальные классы. |
8 |
| -В ней мы опишем вспомогательные методы для работы с вебдрайвером.</p> |
| 7 | +<p>To start, let's create a base page from which all other classes will be inherited. |
| 8 | +In it, we will describe auxiliary methods for working with the web driver.</p> |
9 | 9 |
|
10 |
| -<p>1. В файле <code>base_page.py</code> создайте класс с названием <code>BasePage</code>. </p> |
| 10 | +<p>1. In the <code>base_page.py</code> file, create a class named <code>BasePage</code>. </p> |
11 | 11 |
|
12 |
| -<p>В Python такие вещи делаются с помощью следующей конструкции: </p> |
| 12 | +<p>In Python, such things are done using the following construct: </p> |
13 | 13 |
|
14 | 14 | <pre>
|
15 | 15 | <code>class BasePage:</code></pre>
|
16 | 16 |
|
17 |
| -<p>2. Теперь в наш класс нужно добавить методы. |
18 |
| -Первым делом добавим <em>конструктор — </em>метод, который вызывается, когда мы создаем объект. Конструктор объявляется ключевым словом <code>__init__</code>. В него в качестве параметров мы передаем экземпляр драйвера и url адрес. Внутри конструктора сохраняем эти данные как аттрибуты нашего класса. Получается примерно так: </p> |
| 17 | +<p>2. Now we need to add methods to our class. |
| 18 | +First of all, let's add a <em>constructor — </em>a method that is called when we create an object. A constructor is declared with the keyword <code>__init__</code>. As parameters, we pass an instance of the driver and the URL address. Inside the constructor, we save this data as attributes of our class. It looks like this: </p> |
19 | 19 |
|
20 | 20 | <pre>
|
21 | 21 | <code class="language-python">def __init__(self, browser, url):
|
22 | 22 | self.browser = browser
|
23 | 23 | self.url = url</code></pre>
|
24 | 24 |
|
25 |
| -<p>3. Теперь добавим еще один метод open. Он должен открывать нужную страницу в браузере, используя метод get().</p> |
| 25 | +<p>3. Now let's add another method, open. It should open the required page in the browser using the get() method.</p> |
26 | 26 |
|
27 |
| -<p>Объявите ниже в том же классе:</p> |
| 27 | +<p>Declare the following in the same class:</p> |
28 | 28 |
|
29 | 29 | <pre>
|
30 | 30 | <code class="language-python">def open(self):</code></pre>
|
31 | 31 |
|
32 |
| -<p>и реализуйте этот метод: нужна всего одна строка. |
| 32 | +<p>And implement this method: it only needs one line. |
33 | 33 | </p>
|
0 commit comments