Пример #1
0
    def do_login(self):
        if self._is_logged_in():
            log ("Already signed in")
            return True

        log('Signing in')
        click_element_when_available(self.browser.find_element_by_link_text, "Inloggen")
        time.sleep(1)

        email = [f for f in self.browser.find_elements_by_xpath("//input[@ng-model='email']") if f.is_displayed()][0]
        passwd = [f for f in self.browser.find_elements_by_xpath("//input[@ng-model='password']") if f.is_displayed()][0]
        button = [f for f in self.browser.find_elements_by_xpath("//input[@value='Login']") if f.is_displayed()][0]

        email.send_keys(USERNAME)
        passwd.send_keys(PASSWORD)
        button.click()

        counter = 0
        log('Waiting max. 10 seconds')
        while not self._is_logged_in():
            time.sleep(1)
            counter += 1
            log(counter)
            if counter > 10:
                log('Login failed.')
                make_screenshot(self.browser)
                return False
        else:
            log('Logged in successfully.')
            return True
Пример #2
0
    def do_place_bid(self, price):
        log("ACTION is %s" % self.action)
        if self.action != "bid":
            log("We are doing a dry run. Not bidding!")
            return

        if int(price) > int(self.max_price):
            raise RuntimeError("FAILSAFE (this should not happen): not placing bid of %s, it's higher than %s" %
                (price, self.max_price))
        else:
            log("Placing bid of '%s' euro" % price)
            ub = self.browser.find_element_by_xpath("//input[@name='bidAmount']")
            # first clear the input field!
            log('DEBUG: Clearing input field')
            ub.clear()
            log('DEBUG: Sending %s to input field' % price)
            ub.send_keys(price)
            click_element_when_available(self.browser.find_element_by_link_text, "Bied mee!")

#            click_element_when_available(self.browser.find_elements_by_link_text, "Plaats bod", max_tries=5)
            time.sleep(0.2)
            try:
                self.browser.find_element_by_link_text("Plaats bod").click()
            except (ElementNotVisibleException, NoSuchElementException):
                # This can happen when auto-confirm is checked.
                log("Could not confirm, this is probably OK.")

            log('Placed bid for %s EUR' % price)
            time.sleep(0.2)
            # Try to close all dialogs:
            log('DEBUG: Closing any dialogs')
            for dialog in self.browser.find_elements_by_class_name('DialogClose'):
                log("Encountered dialog with text: '%s'" % dialog.text)
                try:
                    dialog.click()
                    log('Closed a dialog window.')
                except ElementNotVisibleException:
                    log("Could not close invisible dialog")
                except:
                    log('Failed to close a dialog.')
            log('DEBUG: Done closing any dialogs')
Пример #3
0
    def do_place_bid(self, price):
        log("ACTION is %s" % self.action)
        if self.action != "bid":
            log("We are doing a dry run. Not bidding! Creating screenshot instead.")
            make_screenshot(self.browser)
            return

        if int(price) > int(self.max_price):
            log("FAILSAFE (this should not happen): not placing bid of %s, it's higher than %s" % (price, self.max_price))
        else:
            log("Placing bid of '%s' euro" % price )
            ub = self.browser.find_element_by_id('userBid')
            # first clear the input field!
            log('DEBUG: Clearing input field')
            ub.clear()
            log('DEBUG: Sending %s to input field' % price)
            ub.send_keys(price)

#            log('DEBUG: Sending ENTER to input field')
#            keys = webdriver.common.keys.Keys()
#            ub.send_keys(keys.ENTER)

            log("DEBUG: Clicking Bid button")
            bb = self.browser.find_element_by_id('bidButton')
            bb.click()

            time.sleep(0.1)
            log('DEBUG: Clicking YES')
            click_element_when_available(self.browser.find_element_by_class_name, "yesButton")

            time.sleep(0.1)
            log('DEBUG: Clicking OK')
            click_element_when_available(self.browser.find_element_by_class_name, "yesButtonCentered")

            log('Placed bid for %s EUR' % price)
            time.sleep(0.2)