Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions airgun/entities/job_invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def get_targeted_hosts(self):
time.sleep(3)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider replacing chained time.sleep(3) calls with an explicit wait on the relevant UI condition.

There are now two fixed 3-second sleeps around the next_button interaction, which both slow the test and remain brittle if the page timing changes. Please replace these with an explicit wait (e.g., waiting for next_button to be clickable or for the target hosts view to appear) to improve reliability and reduce runtime.

Suggested implementation:

        view = JobInvocationCreateView(self.browser)
        # Explicitly wait until the "next" button is clickable instead of using fixed sleeps
        WebDriverWait(self.browser, 10).until(
            EC.element_to_be_clickable(view.next_button)
        )
        view.next_button.click()
        self.browser.plugin.ensure_page_safe()
        time.sleep(3)
        return view.target_hosts_and_inputs.read()

To fully implement this change, you will also need to:

  1. Add the appropriate imports at the top of airgun/entities/job_invocation.py, for example:
    • from selenium.webdriver.support.ui import WebDriverWait
    • from selenium.webdriver.support import expected_conditions as EC
  2. If self.browser is not the raw Selenium WebDriver instance, adjust the WebDriverWait call to use the underlying driver (e.g., self.browser.driver), consistent with how other explicit waits are implemented in this codebase.
  3. If the project already has helper methods for explicit waits (e.g., in self.browser.plugin), you may prefer to replace the WebDriverWait block with the project-standard helper for waiting until an element is clickable.

view = JobInvocationCreateView(self.browser)
time.sleep(3)
if view.next_button.is_displayed and view.next_button.is_enabled:
view.next_button.click()
self.browser.plugin.ensure_page_safe()
time.sleep(3)
return view.target_hosts_and_inputs.read()

def read_hostgroups(self):
Expand Down