コード例 #1
0
 def test_add_location(self):
     driver = self.driver
     driver.maximize_window()
     driver.get(self.base_url)
     driver.find_element_by_id("user_email").send_keys("*****@*****.**")
     driver.find_element_by_id("user_password").send_keys("NatAw1988")
     driver.find_element_by_name("commit").click()
     #wait until home page will be loaded
     WebDriverWait(driver, 30).until(
         lambda element: element.find_element_by_xpath("//div[contains(.,'Locations')]").is_displayed(),
         'Timeout my friend.'
                                     )
     #click to add location
     driver.find_element_by_xpath("//md-content[@id='content']/section/md-content/div/home-dashboard/div/section/md-toolbar/div/a/md-icon").click()
     WebDriverWait(driver, 10).until(
         lambda element: element.find_element_by_xpath("//div[contains(.,'Please enter a location name')]").is_displayed(),
         'Timeout.')
     #generating location names
     NewName = address.generateName(5, 30)
     NewAddress = address.generateAddress(6, 50)
     NewCity = address.generateCity(3, 20)
     NewPostcode = address.generatePostcode(2, 8)
     print NewName
     driver.find_element_by_id("input_53").clear()
     driver.find_element_by_id("input_53").send_keys(NewName)
     driver.find_element_by_id("input_54").clear()
     driver.find_element_by_id("input_54").send_keys(NewAddress)
     driver.find_element_by_id("input_55").clear()
     driver.find_element_by_id("input_55").send_keys(NewCity)
     driver.find_element_by_id("input_56").clear()
     driver.find_element_by_id("input_56").send_keys(NewPostcode)
     SaveButton = driver.find_element_by_xpath("//button[@type='submit']").submit()
     WebDriverWait(driver, 10).until(
         lambda element: element.find_element_by_xpath("//div[contains(.,'Please Add a Device')]").is_displayed(),
         'Timeout.')
     #go to the home page
     driver.find_element_by_css_selector("img.devolo_logo.devolo_logo_lg").submit()
     WebDriverWait(driver, 10).until(
         lambda element: element.find_element_by_xpath("//div[contains(.,'Locations')]").is_displayed(),
         'Timeout.')
     driver.find_element_by_xpath("//md-content[@id='content']/section/md-content/div/home-dashboard/div/md-content/div/dashing/md-card/md-card-content/md-list-item[3]/div/a").click()
     WebDriverWait(driver, 10).until(
         lambda element: element.find_element_by_xpath("//div[contains(.,'Address')]").is_displayed(),
         'Timeout.')
     driver.find_element_by_link_text(NewName).click()
     WebDriverWait(driver, 10).until(
         lambda element: element.find_element_by_xpath("//div[contains(.,'Settings')]").is_displayed(),
         'Timeout.') 
     #click settings button
     driver.find_element_by_xpath("//md-content[@id='content']/section/md-sidenav[2]/md-content/ul/li[14]/menu-link/a/span").click()
     WebDriverWait(driver, 10).until(
         lambda element: element.find_element_by_xpath("//div[contains(.,'Details')]").is_displayed(),
         'Timeout.') 
     # deleting location 
     # clicking action button
     driver.find_element_by_xpath("(//button[@type='button'])[5]").click()
     # click delete
     driver.find_element_by_xpath("(//button[@type='button'])[32]").click()
     # submit deleting 
     driver.find_element_by_xpath("(//button[@type='button'])[34]").click()
コード例 #2
0
def main():
    driver_factory = LocalFirefox()
    config={
              "Open" : {
                        "base_url": "https://bs-ct-dev.devolo.net"
                        },
              "Login": {
                        "login": "******",
                        "password": "******"
                        },
            "LocationData" : {
                              "new_name": address.generateName(5, 30),
                              "new_address": address.generateAddress(6, 50),
                              "new_city": address.generateCity(3, 20),
                              "new_postcode": address.generatePostcode(3, 8)
                              }
            }
    
    OpenLoginLocationlistClose().execute(driver_factory.get(), config)