Skip to content

Commit 6bf7405

Browse files
author
Cleverson Sampaio
committed
feat(module): added navigation module
navigation module with methods to open browser, navigate to url, navigate back, retrieve page title and reload page
1 parent 43e8fb7 commit 6bf7405

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2022 Cléverson Sampaio <cleverson@sampaio.dev.br>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2022 Cléverson Sampaio <cleverson@sampaio.dev.br>
5+
6+
from robot.libraries.BuiltIn import BuiltIn
7+
from robot.api.deco import keyword
8+
from SeleniumLibraryExtends.report import Report
9+
10+
class Navigation:
11+
def __init__(self):
12+
pass
13+
14+
@keyword("I open the browser ${browser}")
15+
def openBrowser(self, browser: str, maximize: bool = True):
16+
self.driver = BuiltIn().get_library_instance("SeleniumLibrary")
17+
self.driver.open_browser("about:blank", browser)
18+
if maximize:
19+
self.driver.maximize_browser_window()
20+
21+
@keyword("I am on ${url}")
22+
def navigateTo(self, url: str):
23+
self.driver = BuiltIn().get_library_instance("SeleniumLibrary")
24+
self.driver.go_to(url)
25+
try:
26+
self.driver.wait_until_element_is_visible("tag:body")
27+
except Exception as e:
28+
Report().fail(e)
29+
30+
@keyword("I navigate back")
31+
def back(self):
32+
self.driver = BuiltIn().get_library_instance("SeleniumLibrary")
33+
self.driver.go_back()
34+
35+
@keyword("I retrieve the page title")
36+
def getTitle(self) -> str:
37+
self.driver = BuiltIn().get_library_instance("SeleniumLibrary")
38+
return self.driver.get_title()
39+
40+
@keyword("I refresh page")
41+
def refresh(self):
42+
self.driver = BuiltIn().get_library_instance("SeleniumLibrary")
43+
self.driver.reload_page()

0 commit comments

Comments
 (0)