Skip to content

Commit

Permalink
Add support for getting documentaion related urls from Satellite page
Browse files Browse the repository at this point in the history
  • Loading branch information
jameerpathan111 committed Oct 29, 2024
1 parent e4dd68a commit ba1ff60
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 0 deletions.
19 changes: 19 additions & 0 deletions airgun/entities/about.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from airgun.entities.base import BaseEntity
from airgun.navigation import NavigateStep, navigator
from airgun.utils import retry_navigation
from airgun.views.about import AboutView


class AboutEntity(BaseEntity):
endpoint_path = '/about'


@navigator.register(AboutEntity, 'All')
class ShowAboutPage(NavigateStep):
"""Navigate to About page."""

VIEW = AboutView

@retry_navigation
def step(self, *args, **kwargs):
self.view.menu.select('Administer', 'About')
19 changes: 19 additions & 0 deletions airgun/entities/fact_value.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from airgun.entities.base import BaseEntity
from airgun.navigation import NavigateStep, navigator
from airgun.utils import retry_navigation
from airgun.views.fact import HostFactView


class FactValueEntity(BaseEntity):
endpoint_path = '/fact_values'


@navigator.register(FactValueEntity, 'All')
class ShowFactValuePage(NavigateStep):
"""Navigate to Fact Values page."""

VIEW = HostFactView

@retry_navigation
def step(self, *args, **kwargs):
self.view.menu.select('Monitor', 'Facts')
19 changes: 19 additions & 0 deletions airgun/entities/global_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from airgun.entities.base import BaseEntity
from airgun.navigation import NavigateStep, navigator
from airgun.utils import retry_navigation
from airgun.views.global_parameter import GlobalParameterView


class GlobalParameterEntity(BaseEntity):
endpoint_path = '/common_parameters'


@navigator.register(GlobalParameterEntity, 'All')
class ShowGlobalParameters(NavigateStep):
"""Navigate to Global Parameters page."""

VIEW = GlobalParameterView

@retry_navigation
def step(self, *args, **kwargs):
self.view.menu.select('Configure', 'Global Parameters')
18 changes: 18 additions & 0 deletions airgun/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from airgun import settings
from airgun.browser import AirgunBrowser, SeleniumBrowserFactory
from airgun.entities.about import AboutEntity
from airgun.entities.acs import AcsEntity
from airgun.entities.activationkey import ActivationKeyEntity
from airgun.entities.all_hosts import AllHostsEntity
Expand Down Expand Up @@ -37,8 +38,10 @@
from airgun.entities.domain import DomainEntity
from airgun.entities.eol_banner import EOLBannerEntity
from airgun.entities.errata import ErrataEntity
from airgun.entities.fact_value import FactValueEntity
from airgun.entities.file import FilesEntity
from airgun.entities.filter import FilterEntity
from airgun.entities.global_parameter import GlobalParameterEntity
from airgun.entities.hardware_model import HardwareModelEntity
from airgun.entities.host import HostEntity
from airgun.entities.host_new import NewHostEntity
Expand Down Expand Up @@ -328,6 +331,11 @@ def acs(self):
"""Instance of Alternate Content Sources entity."""
return self._open(AcsEntity)

@cached_property
def about(self):
"""Instance of About entity."""
return self._open(AboutEntity)

@cached_property
def activationkey(self):
"""Instance of Activation Key entity."""
Expand Down Expand Up @@ -457,6 +465,11 @@ def errata(self):
"""Instance of Errata entity."""
return self._open(ErrataEntity)

@cached_property
def factvalue(self):
"""Instance of Fact Value entity."""
return self._open(FactValueEntity)

@cached_property
def filter(self):
"""Instance of Filter entity."""
Expand All @@ -467,6 +480,11 @@ def file(self):
"""Instance of Files entity."""
return self._open(FilesEntity)

@cached_property
def global_parameter(self):
"""Instance of Global Parameters entity."""
return self._open(GlobalParameterEntity)

@cached_property
def hardwaremodel(self):
"""Instance of Hardware Model entity."""
Expand Down
11 changes: 11 additions & 0 deletions airgun/views/about.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from widgetastic.widget import Text

from airgun.views.common import BaseLoggedInView, SearchableViewMixinPF4


class AboutView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='About']")

@property
def is_displayed(self):
return self.browser.wait_for_element(self.title, exception=False) is not None
30 changes: 30 additions & 0 deletions airgun/views/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from selenium.common.exceptions import ElementNotInteractableException
from widgetastic.widget import (
Checkbox,
ConditionalSwitchableView,
Expand Down Expand Up @@ -80,6 +81,35 @@ def read(self, widget_names=None, limit=None):
values[widget_name] = widget.read()
return normalize_dict_values(values)

def documentation_links(self):
"""Return Documentation links present on the given page if any.
Note: This is not a full-proof helper. For example, it can't get links hidden behind a dropdown button.
"""
doc_link_elements = (
'//a[contains(text(), "documentation") or contains(text(), "Documentation") or '
'contains(@class, "btn-docs") or contains(@href, "console.redhat.com") or '
'contains(@href, "access.redhat.com") or contains(@href, "docs.redhat.com") or '
'contains(@href, "www.redhat.com") or contains(@href, "links")]'
)
doc_links = []
for item in self.browser.elements(doc_link_elements):
try:
item.click()
if len(self.browser.window_handles) == 1:
doc_links.extend([self.browser.url])
self.browser.selenium.back()
else:
self.browser.switch_to_window(self.browser.window_handles[1])
doc_links.extend([self.browser.url])
self.browser.switch_to_window(self.browser.window_handles[0])
self.browser.close_window(self.browser.window_handles[1])
except ElementNotInteractableException:
# Adding this because some links are hidden behind dropdown button.
# To Do: Handle doc buttons hidden behind drop down buttons.
doc_links.extend([item.get_attribute('href')])
continue
return doc_links


class WrongContextAlert(View):
"""Alert screen which appears when switching organization while organization-specific entity is
Expand Down
11 changes: 11 additions & 0 deletions airgun/views/global_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from widgetastic.widget import Text

from airgun.views.common import BaseLoggedInView, SearchableViewMixinPF4


class GlobalParameterView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Global Parameters']")

@property
def is_displayed(self):
return self.browser.wait_for_element(self.title, exception=False) is not None

0 comments on commit ba1ff60

Please sign in to comment.