def test_firmware(self):
        self.driver.find_element_by_xpath("//*[@id='fwupdate']/a").click()
        self.driver.switch_to_frame("center")
        wait = WebDriverWait(self.driver, 10)
        wait.until(
            expected_conditions.visibility_of_element_located(
                (By.XPATH, "//*[@id='fwupdateForm']/p[2]/input")))
        self.driver.find_element_by_xpath(
            "//*[@id='fwupdateForm']/p[2]/input").click()
        sleep(1)
        robot = Robot()
        robot.add_to_clipboard("I:\Share\Umesh\Firmware\DTE\dte101_1.2.6.nxf")
        robot.paste()
        robot.press_and_release(Keys.enter)

        self.driver.find_element_by_xpath("//input[@type='submit']").click()
        wait.until(
            expected_conditions.visibility_of_element_located(
                (By.XPATH, "//*[@id='contentIframe']/p[1]/b")))
        self.assertEqual(
            self.driver.find_element_by_xpath(
                "//*[@id='contentIframe']/p[1]/b").text,
            "Firmware transfer and update succeeded!")
        sleep(1)
        self.driver.find_element_by_xpath("//input[@type='checkbox']").click()
        self.driver.find_element_by_xpath("//input[@type='submit']").click()
        wait.until(
            expected_conditions.visibility_of_element_located(
                (By.XPATH, "//*[@id='contentIframe']/p[1]")))
        self.assertEqual(
            self.driver.find_element_by_xpath(
                "//*[@id='contentIframe']/p[1]").text,
            "The device was successfully restarted.")
        self.verify_settings()
    def test_setUp(self):
        Util.init_ChromeDriver(self)
        #Util.init_IE_Driver(self)

        self.driver.maximize_window()
        self.driver.get('http://192.168.0.79')
        yield
        self.driver.switch_to_default_content()
        sleep(2)
        self.driver.find_element_by_id('system').click()
        #self.driver.find_element_by_id('system').click()
        sleep(2)
        robot = Robot()
        robot.add_to_clipboard("admin")
        robot.paste()
        sleep(1)
        robot.press_and_release(Keys.tab)
        sleep(1)
        robot.add_to_clipboard("iepl")
        robot.paste()
        sleep(1)
        robot.press_and_release(Keys.enter)
        self.driver.switch_to_frame("center")
        wait = WebDriverWait(self.driver, 10)
        wait.until(
            expected_conditions.visibility_of_element_located(
                (By.XPATH, "//*[@id='pwpForm']//input[@value='off']")))
        self.driver.find_element_by_xpath(
            "//*[@id='pwpForm']//input[@value='off']").click()
        self.setPassword("iepl", "admin")
        self.driver.quit()
示例#3
0
def order(k, folder_name, path_upload, photo_path_final):

    #Lauching chrome in mobile version
    mobileEmulation = {'deviceName': 'Pixel 2'}
    options = webdriver.ChromeOptions()
    options.add_experimental_option('mobileEmulation', mobileEmulation)
    driver = webdriver.Chrome(executable_path='chromedriver.exe',
                              chrome_options=options)

    #setting the photo_path and the caption text
    photo_path = photo_path_final
    caption_path = path_upload + '\\' + folder_name + '\\text.txt'
    print(photo_path)
    content_array = []
    with open(caption_path) as f:
        for line in f:
            content_array.append(line)
    print(content_array)

    #going to instagram page and loging in
    driver.get(k['URL_insta'])
    time.sleep(1)
    driver.find_element_by_name('username').send_keys(k["username"])
    driver.find_element_by_name('password').send_keys(k["password"])
    driver.find_element_by_name('password').send_keys(Keys.RETURN)
    wait = ui.WebDriverWait(driver, 20)

    #dealing with the popups
    time.sleep(10)
    if driver.find_element_by_xpath(
            '/html/body/div[3]/div/div/div[3]/button[2]') != 0:
        driver.find_element_by_xpath(
            '/html/body/div[3]/div/div/div[3]/button[2]').click()

    #Photo being selected and uploaded
    time.sleep(4)
    robot = Robot()
    xerox.copy(photo_path_final)
    driver.find_element_by_xpath(
        '//*[@id="react-root"]/section/nav[2]/div/div/div[2]/div/div/div[3]'
    ).click()
    time.sleep(4)
    robot.paste()
    robot.press_and_release('enter')

    #photo being adjusted
    time.sleep(2)
    driver.find_element_by_xpath(
        '//*[@id="react-root"]/section/div[2]/div[2]/div/div/div/button[1]'
    ).click()
    driver.find_element_by_xpath(
        '//*[@id="react-root"]/section/div[1]/header/div/div[2]/button').click(
        )

    #Putting the caption and posting the image
    time.sleep(2)
    driver.find_element_by_xpath(
        '//*[@id="react-root"]/section/div[2]/section[1]/div[1]/textarea'
    ).click()
    driver.find_element_by_xpath(
        '//*[@id="react-root"]/section/div[2]/section[1]/div[1]/textarea'
    ).send_keys(content_array)
    driver.find_element_by_xpath(
        '//*[@id="react-root"]/section/div[1]/header/div/div[2]/button').click(
        )

    #Posting the image
    time.sleep(15)
    driver.quit()
    done = "Photo:" + photo_path + " Successfully uploaded"
    print(done)
    return done
示例#4
0
def dgcUpload(file):

    print('Inside function')
    print(file)
    #Set browser (Firefox) to be opened
    browser = webdriver.Firefox()

    #Open DGC instance on local machine
    dgcWebLink = 'http://localhost:4400/'
    browser.get(dgcWebLink)

    #User credentials
    user_acc = "Admin"
    user_pas = "******"

    #Pass in credentials
    user = browser.find_element_by_css_selector(
        'div.row:nth-child(2) > div:nth-child(1) > span:nth-child(1)')
    user.send_keys(user_acc)

    pass_key = browser.find_element_by_css_selector(
        'div.row:nth-child(3) > div:nth-child(1) > div:nth-child(2) > input:nth-child(1)'
    )
    pass_key.send_keys(user_pas)

    #Click 'Signin' button to login into DGC
    login = browser.find_element_by_css_selector('.uf-normal-button').click()

    #Wait for 20 seconds for the page to load
    timeout = 20
    try:
        WebDriverWait(browser, timeout).until(
            EC.visibility_of_element_located(
                (By.CSS_SELECTOR, 'a.item:nth-child(6)')))
    except TimeoutException:
        print("Browser didn't load properly")
        browser.quit()

    #Click 'Settings' on DGC
    settings = browser.find_element_by_css_selector(
        'a.item:nth-child(6)').click()

    # Wait for 20 seconds for the page to load
    timeout = 20
    try:
        WebDriverWait(browser, timeout).until(
            EC.visibility_of_element_located(
                (By.CSS_SELECTOR, 'li.maintab:nth-child(6)')))
    except TimeoutException:
        print("Browser didn't load properly")
        browser.quit()

    #Click 'Workflows' on the left hand side
    workflows = browser.find_element_by_css_selector(
        'li.maintab:nth-child(6)').click()

    # Wait for 20 seconds for the page to load
    timeout = 10
    try:
        WebDriverWait(browser, timeout).until(
            EC.visibility_of_element_located(
                (By.CSS_SELECTOR, '.fileupload-button')))
    except TimeoutException:
        print("Browser didn't load properly")
        browser.quit()

    #Click 'Deploy' to upload the workflow
    deploy = browser.find_element_by_css_selector('.fileupload-button').click()

    pyperclip.copy(file)

    # Wait for 10 seconds for the page to load
    for i in range(1, 25):
        print('')

    robot = Robot()
    robot.paste()

    # Wait for 10 seconds for the page to load
    for i in range(1, 25):
        print('')

    robot.key_press('enter')
    print('pressed enter')

    # browser.find_element_by_xpath("//button[contains(text(), 'Open')]").click()

    robot.key_release('enter')
    print('released enter')