示例#1
0
 def myclick(self):
     self.ele = BaseElement()
     #self.ele.driver.find_element_by_xpath("//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.view.View[4]").click()
     return self.ele.get_xpath(
         "//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.view.View[4]"
     )
     logging.info("点击我的按钮,进入我的页面")
示例#2
0
 def submit_RFQ(self):
     locator = Locator(
         By.CSS_SELECTOR,
         "button.next-btn.next-medium.next-btn-primary.submit-btn")
     element = BaseElement(self.driver, locator)
     element.click_button()
     self.driver.close()
示例#3
0
 def send_message(self):
     locator = Locator(
         By.CSS_SELECTOR,
         "input.ui2-button.ui2-button-default.ui2-button-primary.ui2-button-large"
     )
     element = BaseElement(self.driver, locator)
     element.click_button()
def test_category():
    ce = ComposedElement()
    be = BaseElement("Test", "TestDesc", "category")
    be2 = BaseElement("Test2 ", "TestDesc2", "category")
    be3 = BaseElement("Test3", "TestDesc3", "category2")

    ce.addElement(be)
    ce.addElement(be2)
    ce.addElement(be3)

    eg = ce.getElementsByCategory("category")
    assert ([be, be2] == eg or [be2, be] == eg)
示例#5
0
def test_idAction():
    cat1 = "ACTION1"
    cat2 = "ACTION2"
    cat3 = "ACTION3"
    be2 = BaseElement("action two", "second action", cat2)
    be3 = BaseElement("action_three", "third action", cat3)
    be = BaseElement("action_one", "first action", cat1)
    d = {
            cat1: be,
            cat3: be3,
            cat2: be2
    }
    o = Action(d, 1)
    idObs = o.getID()
    assert idObs == "action_one|||action_three|||action two"
示例#6
0
def test_id():
    cat1 = "OBSERVATION_ONE"
    cat2 = "OBSERVATION_TWO"
    cat3 = "OBSERVATION_THREE"
    be2 = BaseElement("secondObservation", "The second observation", cat2)
    be3 = BaseElement("thirdObservation", "The third observation", cat3)
    be = BaseElement("firstObservation", "The first observation", cat1)
    d = {
            cat1: be,
            cat3: be3,
            cat2: be2
    }
    o = Observation(d)
    idObs = o.getID()
    assert idObs == "firstObservation|||secondObservation|||thirdObservation"
示例#7
0
 def createObservation(self, header, row):
     """Create an action from a row
     :row: the row
     :returns: the parsed action
     """
     idRow = row[0]
     observationElements = {}
     for i in range(len(header)):
         if CSVObservations.DELIMITER_OBSERVATION in header[i]:
             # Take all the actions of the category
             category = header[i]
             idObservation = row[i]
             # Get all elements of the category
             categoryElements = self.actionElements.getElementsByCategory(
                 category)
             # Get the currect value for that action
             if idObservation != "":
                 obsInstance = categoryElements.getElement(idObservation)
                 if obsInstance is None:
                     print "WARN: no %s idObservation" % (idObservation)
                 observationElements[category] = obsInstance
             else:
                 obsInstance = categoryElements.getElement(idObservation)
                 obsInstance = BaseElement.empty(category)
                 observationElements[category] = obsInstance
     return Observation(observationElements, idRow)
示例#8
0
    def createAction(self, header, row):
        """Create an action from a row
        :row: the row
        :returns: the parsed action
        """
        rank = 1
        idRow = row[0]
        actionElements = {}
        for i in range(len(header)):
            if CSVActions.ACTION_ID == header[i]:
                rank = row[i]
            elif CSVActions.DELIMITER_ACTION in header[i]:
                # Take all the actions of the category
                category = header[i]
                idAction = row[i]
                # Get all elements of the category

                categoryElements = self.actionElements.getElementsByCategory(category)
                if idAction != "":
                    # Get the currect value for that action
                    actionInstance = categoryElements.getElement(idAction)
                    if actionInstance is None:
                        print "WARN: no %s idAction" % (idAction)
                    actionElements[category] = actionInstance
                else:
                    actionInstance = BaseElement.empty(category)
                    actionElements[category] = actionInstance

        return Action(actionElements, rank, idRow)
        pass
def test_remove():
    ce = ComposedElement()
    be = BaseElement("Test", "TestDesc", "category")
    ce.addElement(be)

    assert be == ce.getElement("Test")
    ce.removeElement("Test")
    assert (ce.getElement("Test") is None)
示例#10
0
def test_withEmptyElements():
    e1 = BaseElement.empty("TEST")
    cat1 = "OBSERVATION_ONE"
    cat2 = "OBSERVATION_TWO"
    cat3 = "OBSERVATION_THREE"
    be2 = BaseElement("secondObservation", "The second observation", cat2)
    be3 = BaseElement("thirdObservation", "The third observation", cat3)
    be = BaseElement("firstObservation", "The first observation", cat1)

    d = {
            cat1: be,
            cat3: be3,
            cat2: be2,
            "TEST": e1
    }
    o = Observation(d)
    idObs = o.getID()
    assert idObs == "firstObservation||||||secondObservation|||thirdObservation"
示例#11
0
 def _readObservationFile(self):
     """Docstring for readActionFile """
     csvObj = CSVUtil.readCSV(self.observationFile, self.delimiter)
     rows = csvObj['listRows']
     self.actionElements = ComposedElement()
     # Use for loop to print csv row by row
     for row in rows:
         be = BaseElement(row[0], row[1], row[2].lower())
         self.actionElements.addElement(be)
示例#12
0
def testEqualityObs():
    e1 = BaseElement.empty("TEST")
    cat1 = "OBSERVATION_ONE"
    cat2 = "OBSERVATION_TWO"
    cat3 = "OBSERVATION_THREE"
    be2 = BaseElement("secondObservation", "The second observation", cat2)
    be3 = BaseElement("thirdObservation", "The third observation", cat3)
    be = BaseElement("firstObservation", "The first observation", cat1)

    d = {
            cat1: be,
            cat3: be3,
            cat2: be2,
            "TEST": e1
    }
    o = Observation(d)
    o2 = Observation(d)
    assert o == o2
示例#13
0
    def __init__(self, driver):
        super().__init__(driver)
        self.go()

        locator = Locator(By.CSS_SELECTOR, "button#wzrk-cancel")
        button = BaseElement(self.driver, locator=locator)
        button.click_button()

        locator = Locator(By.CSS_SELECTOR, "button.Popup-button")
        button = BaseElement(self.driver, locator=locator)
        button.click_button()
示例#14
0
 def select_emirate(self):
     locator = Locator(
         By.CSS_SELECTOR,
         "#root > div > div.Base-content > div > div.Checkout-content > div.Delivery-signInAndShippingAddress > form > section.NewAddress > label:nth-child(5) > div > div > span"
     )
     element = BaseElement(self.driver, locator=locator)
     ActionChains(self.driver).move_to_element(element.web_element).click(
         element.web_element).send_keys(Keys.ARROW_DOWN).send_keys(
             Keys.ENTER).perform()
     time.sleep(10)
示例#15
0
def test_equalityAction():
    cat1 = "ACTION1"
    cat2 = "ACTION2"
    cat3 = "ACTION3"
    be2 = BaseElement("action two", "second action", cat2)
    be3 = BaseElement("action_three", "third action", cat3)
    be = BaseElement("action_one", "first action", cat1)
    d = {
            cat1: be,
            cat3: be3,
            cat2: be2
    }
    d2 = dict(d)
    d2['v'] = BaseElement.empty("v")
    o = Action(d, 1)
    o2 = Action(d, 2)
    o3 = Action(d2, 2)
    assert o == o2
    assert o != o3
示例#16
0
    def contact_supllier(self, message):
        locator = Locator(
            By.CSS_SELECTOR,
            "div a.contact-supplier-btn.organic-gallery-offer__bottom-v2-item.small"
        )
        elements = BaseElement(self.driver, locator).contact_elements
        elements[0].click()

        inp = WebDriverWait(self.driver, 20).until(
            EC.element_to_be_clickable(
                (By.CSS_SELECTOR, 'div textarea#inquiry-content')))
        print(inp)
        inp.send_keys(message)
示例#17
0
 def checkout(self):
     locator = Locator(By.CSS_SELECTOR, "button.CartTotal-secureCheckout")
     return BaseElement(self.driver, locator=locator)
示例#18
0
 def signin_button(self):
     locator = Locator(By.CSS_SELECTOR, "input[type = 'submit']")
     return BaseElement(self.driver, locator=locator)
示例#19
0
 def input_password(self):
     locator = Locator(By.CSS_SELECTOR, "input#fm-login-password")
     return BaseElement(self.driver, locator=locator)
示例#20
0
 def select_color(self):
     locator = Locator(By.CSS_SELECTOR, "button[title = 'Black']")
     return BaseElement(self.driver, locator=locator)
示例#21
0
 def __init__(self, webdriver):
     BaseElement.__init__(webdriver)
示例#22
0
 def select_size(self):
     locator = Locator(By.CSS_SELECTOR, "span.Select-arrow-zone")
     element = BaseElement(self.driver, locator=locator)
     ActionChains(self.driver).move_to_element(element.web_element).click(
         element.web_element).send_keys(Keys.ENTER).perform()
def test_addElement():
    ce = ComposedElement()
    be = BaseElement("Test", "TestDesc", "category")
    ce.addElement(be)
    assert be == ce.getElement("Test")
示例#24
0
 def _continue(self):
     locator = Locator(By.CSS_SELECTOR,
                       "button.ShippingInformationForm-submitButton")
     return BaseElement(self.driver, locator=locator)
示例#25
0
 def add_to_bag(self):
     locator = Locator(By.CSS_SELECTOR, "button.AddToBag")
     return BaseElement(self.driver, locator=locator)
示例#26
0
 def enter_street(self):
     locator = Locator(By.CSS_SELECTOR, "input#street")
     return BaseElement(self.driver, locator=locator)
示例#27
0
 def apartment(self):
     locator = Locator(By.CSS_SELECTOR, "input#additionalInformation")
     return BaseElement(self.driver, locator=locator)
示例#28
0
 def enter_area(self, area):
     locator = Locator(By.CSS_SELECTOR, "input[name = 'city']")
     element = BaseElement(self.driver, locator=locator)
     element.input_text(area)
     element.send_keys(Keys.TAB)
示例#29
0
 def go_to_bag(self):
     locator = Locator(By.XPATH, "//div[text() = 'Bag']")
     return BaseElement(self.driver, locator=locator)
示例#30
0
 def enter_phone_number(self):
     locator = Locator(By.CSS_SELECTOR, "input#mobileNumber")
     return BaseElement(self.driver, locator=locator)