def execute(self, driver, config): # go to main page driver.find_element_by_class_name("devolo_logo_lg").click() # click on locations driver.find_element_by_xpath("//md-card-content/md-list-item[3]/div/a").click() WebDriverWait(driver, 20).until( EC.element_to_be_clickable((By.XPATH, "//md-content[@id='content']/section/md-content/div/list-locations/div[2]/md-content/div/div/md-card/md-toolbar/div/a/md-icon")) ) # create new location driver.find_element_by_xpath("//md-content[@id='content']/section/md-content/div/list-locations/div[2]/md-content/div/div/md-card/md-toolbar/div/a/md-icon").click() WebDriverWait(driver, 20).until( EC.element_to_be_clickable((By.NAME, "location_name")) ) driver.find_element_by_name("location_name").clear() Location_name = address.generateName(5, 30) driver.find_element_by_name("location_name").send_keys(Location_name) print("...Location"+Location_name+" was added") driver.find_element_by_name("location_address").clear() driver.find_element_by_name("location_address").send_keys(config["LocationData"]["new_address"]) driver.find_element_by_name("location_town").clear() driver.find_element_by_name("location_town").send_keys(config["LocationData"]["new_city"]) driver.find_element_by_name("location_postcode").clear() driver.find_element_by_name("location_postcode").send_keys(config["LocationData"]["new_postcode"]) driver.find_element_by_xpath("//button[@type='submit']").submit() driver.find_element_by_class_name("devolo_logo_lg").click() time.sleep(3) """".................add new SSID........................................""" # click locations time.sleep(4) driver.find_element_by_xpath("//md-content[@id='content']/section/md-sidenav[2]/md-content/ul/li[2]/menu-link/a/span").click() # click add new ssid time.sleep(4) driver.find_element_by_xpath("(//button[@type='button'])[8]").click() # adding creditials time.sleep(3) driver.find_element_by_name("ssid").clear() SSID_Name = address.generateName(5, 30) driver.find_element_by_name("ssid").send_keys(SSID_Name) print ("...SSID"+SSID_Name+" was added.") driver.find_element_by_name("password").click() driver.find_element_by_name("password").clear() driver.find_element_by_name("password").send_keys(config["SSID_Credits"]["password"]) # saving new ssid driver.find_element_by_xpath("(//button[@type='button'])[32]").click() time.sleep(3) # clicking on created network driver.find_element_by_link_text(SSID_Name).click() time.sleep(3) # go to main page driver.find_element_by_class_name("devolo_logo_lg").click() print "SSID added"
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()
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)