Skip to content

Commit 2683ffd

Browse files
authored
Merge pull request #58 from jetbrains-academy/stephen-hero-patch-51
Update task.md
2 parents 36ae85f + da4ea99 commit 2683ffd

File tree

1 file changed

+12
-12
lines changed
  • page_object/first_tests_with_po/red_test

1 file changed

+12
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
<h2>Методы-проверки в Page Object</h2>
1+
<h2>Verification methods in Page Object</h2>
22

3-
<p>Давайте теперь автоматизируем другой тест-кейс и посмотрим на его примере, как делать методы-проверки. </p>
3+
<p>Let's now automate another test case and see, through an example, how to create verification methods. </p>
44

5-
<p>Допустим, нам нужно проверять такой сценарий: </p>
5+
<p>Suppose we need to check the following scenario: </p>
66

77
<ol>
8-
<li>Открыть главную страницу </li>
9-
<li>Проверить, что есть ссылка, которая ведет на логин </li>
8+
<li>Open the main page. </li>
9+
<li>Check if there is a link leading to login. </li>
1010
</ol>
1111

12-
<p>Для этого в классе MainPage нужно реализовать метод, который будет проверять наличие ссылки. Обычно все такие методы-проверки называются похожим образом, мы будем называть их should_be_(название элемента). </p>
12+
<p>For this, in the MainPage class, we need to implement a method that will check the presence of the link. Typically, all such verification methods are named similarly; we will call them should_be_(element name). </p>
1313

14-
<p>Итак, в классе MainPage создайте метод <code>should_be_login_link</code>. </p>
14+
<p>So, in the MainPage class, create the method <code>should_be_login_link</code>. </p>
1515

16-
<p>Для первой пробы можно реализовать его самым примитивным образом: </p>
16+
<p>For the first attempt, you can implement it in the simplest way: </p>
1717

1818
<pre><code>def should_be_login_link(self):
1919
self.browser.find_element(By.CSS_SELECTOR, "#login_link_invalid")</code></pre>
2020

21-
<p>Сейчас мы намеренно сделали селектор неправильным, чтобы посмотреть, что именно выдаст тест, если поймает баг. Это хорошая практика: писать сначала красные тесты и только потом делать их зелеными.  </p>
21+
<p>Currently, we intentionally made the selector incorrect to see what the test will report when it catches a bug. This is a good practice: writing red tests first and only then making them green. </p>
2222

23-
<p>Добавляем в файл с тест-кейсами новый тест: </p>
23+
<p>Let's add a new test to the test case file: </p>
2424

2525
<pre><code class="language-python">def test_guest_should_see_login_link(browser):
2626
link = "http://selenium1py.pythonanywhere.com/"
2727
page = MainPage(browser, link)
2828
page.open()
2929
page.should_be_login_link()</code></pre>
3030

31-
<p>Запустите получившийся тест: </p>
31+
<p>Run the resulting test: </p>
3232

3333
<pre><code>pytest -v --tb=line --language=en test_main_page.py</code></pre>
3434

35-
<p>Вывод об ошибке не очень понятный, правда? Разобраться, что именно пошло не так, довольно тяжело. Поэтому в следующем шаге нам нужно будет обработать исключение, которое выбрасывает WebDriver. </p>
35+
<p>The error output is not very clear, right? It's quite challenging to understand what went wrong exactly. Therefore, in the next step, we will need to handle the exception thrown by the WebDriver. </p>

0 commit comments

Comments
 (0)