~canonical-platform-qa/snappy-ecosystem-tests/fixing_ci

« back to all changes in this revision

Viewing changes to snappy_ecosystem_tests/helpers/web_test_base.py

  • Committer: Heber Parrucci
  • Date: 2017-02-15 19:14:19 UTC
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: heber.parrucci@canonical.com-20170215191419-a3549ap02gflc8rj
Addressing review feedback regarding credentials:
Now it is read from a user config file that is outside the repo in the host machine. If that config is not found, then it reads the credentials from env variables.
The idea is to store the config with the credentials in a private repository, and then Jenkins will get it and store in the host machine when running the tests.
The same mechanism is used in ubuntu-system-tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
class UbuntuStoreWebTestsBase(SnappyEcosystemTestCase):
43
43
    """Base class to represent a Web-UI test case.
44
 
    Contain basic functionality for locating web elements and interacting with a page
 
44
    Contain basic functionality for locating web elements and
 
45
    interacting with a page
45
46
    """
46
47
 
47
48
    def setUp(self):
48
 
        # TODO - add support for multiple type browsers including Chrome, FF and IE
 
49
        # TODO - add support for multiple type browsers including Chrome,
 
50
        # FF and IE
49
51
        super().setUp()
50
52
        options = webdriver.ChromeOptions()
51
53
        options.add_argument("--start-maximized")
100
102
            raise
101
103
 
102
104
    def login(self):
103
 
        """Login to web interface, following the UI flow which end user would use"""
 
105
        """Login to web interface, following the UI flow which end user
 
106
        would use"""
104
107
        driver = self.driver
105
108
        driver.get(STORE_URL)
106
109
 
119
122
        self.wait_for_page_title("Your packages")
120
123
 
121
124
    def logout(self):
122
 
        """Logout of web interface, following the UI flow which end user would use"""
 
125
        """Logout of web interface, following the UI flow which end
 
126
        user would use"""
123
127
        driver = self.driver
124
128
        self.wait_for_element((By.CLASS_NAME, "b-dropdown__arrow_light"))
125
129
        #
126
 
        # extremely ugly way to reach the desired element by xpath, a bug will be
 
130
        # extremely ugly way to reach the desired element by xpath,
 
131
        # a bug will be
127
132
        # raised to uniquely identify the dropdown arrows
128
133
        self.wait_for_clickable()
129
 
        down_arrow = driver.find_element_by_xpath("/html/body/nav/div/div[1]/span")
 
134
        down_arrow = driver.find_element_by_xpath(
 
135
            "/html/body/nav/div/div[1]/span")
130
136
        #
131
137
        # There is a bug with Firefox webdriver when clicking elements,
132
138
        # as sometime click doesn't have any effect, to workaround that
133
 
        # multiple attempts are made. However everything works fine with chrome webdriver.
 
139
        # multiple attempts are made. However everything works fine with
 
140
        # chrome webdriver.
134
141
 
135
142
        for _ in range(0, 2):
136
143
            wait = WebDriverWait(self.driver, 1)
137
144
            try:
138
145
                down_arrow.click()
139
 
                element_present = EC.presence_of_element_located((By.CLASS_NAME,
140
 
                                                                  "b-dropdown_open"))
 
146
                element_present = EC.presence_of_element_located(
 
147
                    (By.CLASS_NAME, "b-dropdown_open"))
141
148
                wait.until(element_present)
142
149
                break
143
150
            except TimeoutException:
144
 
                LOGGER.error("Failed to open the accounts dropdown menu card, Trying again")
 
151
                LOGGER.error("Failed to open the accounts dropdown menu card,"
 
152
                             " Trying again")
145
153
 
146
154
        self.wait_for_visible()
147
155
        logout_link = driver.find_element_by_link_text("Log out")