Skip to content

Instantly share code, notes, and snippets.

@abalakh
Created August 22, 2018 16:02
Show Gist options
  • Save abalakh/2404330aaebe0f8154137f1c9af2e6f1 to your computer and use it in GitHub Desktop.
Save abalakh/2404330aaebe0f8154137f1c9af2e6f1 to your computer and use it in GitHub Desktop.
export support for chrome
diff --git a/airgun/browser.py b/airgun/browser.py
index 055d2a3..a2f0ca0 100644
--- a/airgun/browser.py
+++ b/airgun/browser.py
@@ -165,6 +165,11 @@ class SeleniumBrowserFactory(object):
if self.browser == 'chrome':
if binary:
kwargs.update({'executable_path': binary})
+ options = webdriver.ChromeOptions()
+ prefs = {
+ 'profile.default_content_setting_values.automatic_downloads': 1}
+ options.add_experimental_option("prefs", prefs)
+ kwargs.update({'chrome_options': options})
self._webdriver = webdriver.Chrome(**kwargs)
elif self.browser == 'firefox':
if binary:
diff --git a/airgun/entities/contenthost.py b/airgun/entities/contenthost.py
index 7b67dec..354170a 100644
--- a/airgun/entities/contenthost.py
+++ b/airgun/entities/contenthost.py
@@ -79,6 +79,10 @@ class ContentHostEntity(BaseEntity):
view.errata.search(errata_id)
return view.errata.table.read()
+ def export(self):
+ view = self.navigate_to(self, 'All')
+ view.export.click()
+
@navigator.register(ContentHostEntity, 'All')
class ShowAllContentHosts(NavigateStep):
def test_foo(session):
with session:
SAVE_PATH = '/users/andrii/Downloads/'
FILENAME = 'hosts-2018-08-22.csv'
CSV_FILE = '{}{}'.format(SAVE_PATH, FILENAME)
session.organization.select('gHWnJz')
session.contenthost.export()
assert os.path.isfile(CSV_FILE)
with open(CSV_FILE, newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
# not to expose internal URLs
assert row['Name'].endswith('.redhat.com')
pytest -v tests/foreman/ui_airgun/test_activationkey.py -k test_foo
============================= test session starts ==============================
platform darwin -- Python 3.6.4, pytest-3.4.0, py-1.5.3, pluggy-0.6.0 -- /Users/andrii/workspace/py3a/bin/python3.6
cachedir: .pytest_cache
shared_function enabled - OFF - scope: - storage: file
rootdir: /Users/andrii/workspace/robottelo, inifile:
plugins: wait-for-1.0.9, xdist-1.22.0, services-1.2.1, mock-1.6.3, forked-0.2, env-0.6.2
collected 26 items
2018-08-22 18:59:48 - conftest - DEBUG - BZ deselect is disabled in settings
tests/foreman/ui_airgun/test_activationkey.py::test_foo PASSED [100%]
============================= 25 tests deselected ==============================
=================== 1 passed, 25 deselected in 47.52 seconds ===================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment