Exemple #1
0
def send_files():
    global doc_filename
    # Attachment Drop Down Menu
    clipButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/div/span')
    clipButton.click()
    time.sleep(1)

    # To send a Document(PDF, Word file, PPT)
    docButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[3]/button'
    )
    docButton.click()
    time.sleep(1)

    docPath = os.getcwd() + "\\Documents\\" + doc_filename

    autoit.control_focus("Open", "Edit1")
    autoit.control_set_text("Open", "Edit1", (docPath))
    autoit.control_click("Open", "Button1")

    time.sleep(3)
    whatsapp_send_button = browser.find_element_by_xpath(
        '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span'
    )
    whatsapp_send_button.click()
def send_attachment(image_path):
    try:
        # Attachment Drop Down Menu
        clipButton = driver.find_element_by_xpath(
            '//*[@id="main"]/header/div[3]/div/div[2]/div/span')
        clipButton.click()
        time.sleep(1)

        # To send Videos and Images.
        mediaButton = driver.find_element_by_xpath(
            '//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button'
        )
        mediaButton.click()
        time.sleep(3)

        autoit.control_focus("Open", "Edit1")
        autoit.control_set_text("Open", "Edit1", (image_path))
        autoit.control_click("Open", "Button1")
        time.sleep(6)

        whatsapp_send_button = driver.find_element_by_xpath(
            '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span'
        )
        whatsapp_send_button.click()
    except Exception as e:
        print(e)
Exemple #3
0
def send_attachment():
    # Attachment Drop Down Menu
    clipButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/div/span')
    clipButton.click()
    time.sleep(1)

    # To send Videos and Images.
    mediaButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button'
    )
    mediaButton.click()
    time.sleep(3)

    hour = datetime.datetime.now().hour

    # After 5am and before 11am scheduled this.
    if (hour >= 5 and hour <= 11):
        image_path = os.getcwd() + "\\Media\\" + 'goodmorning.jpg'
    # After 9pm and before 11pm schedule this
    elif (hour >= 21 and hour <= 23):
        image_path = os.getcwd() + "\\Media\\" + 'goodnight.jpg'
    else:  # At any other time schedule this.
        image_path = os.getcwd() + "\\Media\\" + 'howareyou.jpg'
    # print(image_path)

    autoit.control_focus("Open", "Edit1")
    autoit.control_set_text("Open", "Edit1", (image_path))
    autoit.control_click("Open", "Button1")

    time.sleep(3)
    whatsapp_send_button = browser.find_element_by_xpath(
        '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span'
    )
    whatsapp_send_button.click()
def command_thor_test(command):
    try:
        ai.win_activate('[title:Control a Device]')
    except ai.AutoItError:
        print('AutoItError happened, returned')
        return
    time.sleep(0.1)
    ai.control_focus('[title:Control a Device]','Edit8')
    time.sleep(0.1)
    ai.control_set_text('[title:Control a Device]','Edit8',command)
    time.sleep(1)
    ai.control_click('[title:Control a Device]','Button15')  #clear the command window
    time.sleep(0.5)
    ai.control_click('[title:Control a Device]','Button13')  #send the command work
    time.sleep(2)
    ai.win_activate('[title:NetLinx Studio]')
    time.sleep(1)
    count = 0
    while True:
        count+=1
        print('try '+str(count)+' time')
        out = get_comeback_message()
        if out!='':
            print('congratulations! the output is not empty')
            break
        elif count<=3:
            time.sleep(3)
        else:
            print('even tried 4 times, the output is still empty')
            break
    return out
#%% test the function
#haha=command_thor_test('get status')        
#print(haha)
Exemple #5
0
    def test_pcLogin(self):
        fp = webdriver.FirefoxProfile(r"C:\Users\mhf\AppData\Roaming\Mozilla\Firefox\Profiles\cv6txwo2.default")
        driver = webdriver.Firefox(fp)
        # driver = webdriver.Firefox ()
        driver.get ("https://www.hongkunjinfu.com")
        WebDriverWait (driver, 10).until (EC.presence_of_element_located ((By.ID, 'login')))
        driver.find_element_by_id ('login').send_keys ('14510000051')
        driver.find_element_by_xpath("html/body/div[2]/div[2]/div/ul/li[1]/a").click()

        autoit.win_activate('鸿坤金服——社区金融超市 - Mozilla Firefox')
        print("1111")
        autoit.send('{LCTRL down}'+'{LSHIFT down}'+'{! down}')
        # autoit.send('{LCTRL down}' + '{LALT down}' + '{a down}')
        # driver.find_element_by_id('login').send_keys(Keys.CONTROL + Keys.SHIFT + '!')
        time.sleep(2)
        autoit.win_wait('截取的图片另存为...')
        print("2222")
        autoit.control_focus('截取的图片另存为...','1001')
        print("3333")
        autoit.win_wait("[Class:#32770]",10)
        t = datetime.now().strftime('%Y%m%d%H%M%S')
        name='金服首页'+t
        # autoit.control_set_text('截取的图片另存为...','Edit1','金服网页102')
        autoit.control_set_text('截取的图片另存为...','Edit1',name)
        autoit.control_click('截取的图片另存为...','Button2')
        driver.close()
 def select_value_from_dropdown_list(self, control_id, value_to_select):
     """ 
     Example:
     Select Value From Dropdown List | [NAME:ccboClass_1] | Class Code Sample
     """
     autoit.win_activate('Power Express')
     autoit.control_click('Power Express', control_id)
     autoit.send('{BACKSPACE}')
     autoit.send('{HOME}')
     while 1:
         item_combo_value = autoit.control_get_text('Power Express',
                                                    control_id)
         if item_combo_value == value_to_select:
             autoit.control_focus('Power Express', control_id)
             autoit.send('{ENTER}')
             autoit.send('{TAB}')
             break
         else:
             autoit.control_focus('Power Express', control_id)
             autoit.send('{DOWN}')
         if autoit.control_get_text('Power Express',
                                    control_id) == item_combo_value:
             BuiltIn().fail("Dropdown '" + value_to_select +
                            "' value is not found")
             break
 def get_value_from_dropdown_list(self, control_id):
     """ 
     Returns a list containing all values of the specified dropdown.
     The default dropdown value is retained.
     """
     dropdown_list = []
     autoit.win_activate('Power Express')
     autoit.control_focus('Power Express', control_id)
     original_value = autoit.control_get_text('Power Express', control_id)
     autoit.send('{BACKSPACE}')
     autoit.send('{HOME}')
     while 1:
         item_combo_value = autoit.control_get_text('Power Express',
                                                    control_id)
         dropdown_list.append(item_combo_value)
         autoit.send('{DOWN}')
         if autoit.control_get_text('Power Express',
                                    control_id) == item_combo_value:
             break
     autoit.send('{BACKSPACE}')
     autoit.send('{HOME}')
     for item in dropdown_list:
         if original_value == autoit.control_get_text(
                 'Power Express', control_id):
             break
         else:
             autoit.send('{DOWN}')
     return dropdown_list
Exemple #8
0
    def test_pcLogin(self):
        fp = webdriver.FirefoxProfile(r"C:\Users\mhf\AppData\Roaming\Mozilla\Firefox\Profiles\cv6txwo2.default")
        driver = webdriver.Firefox(fp)
        # driver = webdriver.Firefox ()
        driver.get ("https://www.hongkunjinfu.com")
        WebDriverWait (driver, 10).until (EC.presence_of_element_located ((By.ID, 'login')))
        driver.find_element_by_id ('login').send_keys ('14510000051')
        #保存网页弹出框
        driver.find_element_by_id('login').send_keys(Keys.CONTROL+'s')
        time.sleep(2)
        # autoit.run("notepad.exe")
        # autoit.win_wait_active("[CLASS:Notepad]", 3)
        # autoit.control_send("[CLASS:Notepad]", "Edit1", "hello world{!}")
        # autoit.win_close("[CLASS:Notepad]")
        # autoit.control_click("[Class:#32770]", "Button2")
        # autoit.win_wait
        # autoit.win_wait_active("[CLASS:#32770]",3)
        autoit.win_activate('另存为')
        print("111111")
        autoit.control_focus('另存为','1001')
        print("22222222")
        autoit.win_wait("[Class:#32770]",10)

        autoit.control_set_text('另存为','Edit1','金服网页2')

        # autoit.control_send("[CLASS:#32770]", "Edit1", "hello world{!}")
        # autoit.control_click("[CLASS:#32770]", "Button2")
        autoit.control_click('另存为','Button2')
        driver.close()
Exemple #9
0
 def file_upload(window_name, file_name):
     autoit.win_wait(window_name, 30)
     if not autoit.win_exists(window_name):
         raise Exception("No File Upload Window is found")
     else:
         autoit.win_activate(window_name)
         autoit.control_focus(window_name, "[ID:1148]")
         autoit.control_set_text(window_name, "[ID:1148]", file_name)
         autoit.control_click(window_name, "[ID:1]")
Exemple #10
0
 def download_image(self):
     self.button_choose = self.find.element_by_xpath(lk_conf.button_choose_xpath).click()
     sleep(1)
     autoit.win_wait(lk_conf.autoit_title, lk_conf.autoit_wait)
     autoit.control_focus(lk_conf.autoit_title, lk_conf.autoit_control_edit)
     autoit.control_send(lk_conf.autoit_title, lk_conf.autoit_control_edit, lk_conf.autoit_image_path)
     autoit.control_click(lk_conf.autoit_title, lk_conf.autoit_control_button)
     self.find.element_by_xpath(lk_conf.button_download_xpath).click()
     sleep(3)
Exemple #11
0
def add_data_jpg():  #加载栅格数据jpg格式
    '''添加数据方法一:设置焦点进行传参,添加jpg数据'''
    autoit.mouse_click("left",54,92,1)                                     #点击加载栅格数据
    autoit.win_wait_active(u"打开栅格文件",15)                              #等待窗口活跃,15秒超时
    autoit.control_focus(u"打开栅格文件", "[Class:Edit; instance:1]")       #设置焦点
    autoit.control_set_text(u"打开栅格文件", "[Class:Edit; instance:1]","C:\Users\Administrator\Desktop\GF1.jpg")
    # 输入文本
    autoit.control_click(u"打开栅格文件", "Button1")
    sleep(5)
def handle_dialog(picName):
    attempts = 0
    while attempts <= 5:
        try:
            autoit.control_focus("Open", "Edit1")
            autoit.control_set_text("Open","Edit1",picName)
            autoit.control_send("Open","Edit1","{ENTER}")
            break
        except:
            sleep(.3)
Exemple #13
0
        def sendAttachment():
            global imagename
            if imagename:
                if ',' not in imagename:
                    # Attachment Drop Down Menu
                    clipButton = browser.find_element_by_xpath(
                        '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div[1]/div[1]/span'
                    )
                    clipButton.click()
                    time.sleep(1)

                    # To send Videos and Images.
                    mediaButton = browser.find_element_by_xpath(
                        '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div[1]/span/div/div/ul/li[1]/button'
                    )
                    mediaButton.click()
                    time.sleep(3)
                    imagePath = os.getcwd(
                    ) + "\\AlWhatsApp\\Documents\\" + imagename
                    autoit.control_focus("Open", "Edit1")
                    autoit.control_set_text("Open", "Edit1", (imagePath))
                    autoit.control_click("Open", "Button1")
                    time.sleep(3)
                    whatsapp_send_button = browser.find_element_by_xpath(
                        '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span/div/div/span'
                    )
                    whatsapp_send_button.click()
                if ',' in imagename:
                    imagename = imagename.split(',')
                    for i in imagename:
                        # Attachment Drop Down Menu
                        clipButton = browser.find_element_by_xpath(
                            '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div[1]/div[1]/span'
                        )
                        clipButton.click()
                        time.sleep(1)

                        # To send Videos and Images.
                        mediaButton = browser.find_element_by_xpath(
                            '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div[1]/span/div/div/ul/li[1]/button'
                        )
                        mediaButton.click()
                        time.sleep(3)
                        imagePath = os.getcwd(
                        ) + "\\AlWhatsApp\\Documents\\" + i
                        autoit.control_focus("Open", "Edit1")
                        autoit.control_set_text("Open", "Edit1", (imagePath))
                        autoit.control_click("Open", "Button1")
                        time.sleep(3)
                        whatsapp_send_button = browser.find_element_by_xpath(
                            '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span/div/div/span'
                        )
                        whatsapp_send_button.click()
def test_new_download(browser):
    driver = browser
    download_name = "1Test name"

    # Количесто записей в таблице. Можно и без базы через gui парсить.
    with allure.step(f'count downloads'):
        db_items_default = len(connect("SELECT * FROM oc_download"))
    with allure.step(f'login auth'):
        AuthPage(driver).login(username='******', password='******')
    with allure.step(f'go to Downloads page'
                     ):  # TODO Вынести переход до нужного блока в Base.
        DashboardPage(driver).navigate_to(dashboard_menu='Catalog',
                                          submenu='Downloads')
    with allure.step(f'go to Add download'):
        DownloadsPage(driver).goto_new_download_page()
    with allure.step(f'input download name'):
        DownloadsPage(driver).name_input_fill(download_name)
        # ActionChains(driver).move_to_element(download_name_input).click().send_keys(download_file_name).perform()
    with allure.step(f"Download file with autoIt"):
        DownloadsPage(driver).upload_btn_click()

        # TODO: уйти от autoit, потому что в headless режиме не заработает.
        # Для добавления файла через JavaScript или базу
        # файл с совпадающим именем должен лежать в папке Storage веб-сервера. Либо добавлять через GUI

        time.sleep(1)
        autoit.win_activate("Открытие")
        autoit.control_focus("Открытие", "Edit1")
        autoit.control_set_text(
            "Открытие", "Edit1",
            "G:\\Projects\\SeleniumOpenCart\\page_objects\\admin\\catalog\\test.jpg"
        )
        time.sleep(1)
        autoit.control_click("Открытие", "Button1")
        time.sleep(1)

    with allure.step(f'accept and save download'):
        driver.switch_to.alert.accept()
        DownloadsPage(driver).save_btn_click()
    with allure.step(f'delete created download form database '):
        # Удаление созданной записи из базы
        db_items_new = len(connect("SELECT * FROM oc_download"))
        last_item_id = connect(
            "SELECT download_id FROM oc_download WHERE download_id=(SELECT max(download_id) FROM oc_download)"
        )
        parsed_id = re.findall("\\d+", str(last_item_id))
        row = ("DELETE FROM oc_download WHERE download_id=%s" % parsed_id[0])
        delete_row(row)
        row_desc = "DELETE FROM oc_download_description WHERE download_id=%s" % parsed_id[
            0]
        delete_row(row_desc)
    assert db_items_default + 1 == db_items_new
Exemple #15
0
 def uninstall_sm_build(self):
     
     uninstallPath = utils.get_registry_value("HKEY_LOCAL_MACHINE", "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\SystemManager", "UninstallString")
     if uninstallPath != "" and uninstallPath != None:
         os.startfile(uninstallPath)
         autoit.win_wait_active("imVision System Manager Setup")
         autoit.control_focus("imVision System Manager Setup", "[NAME:buttonNext]")
         autoit.control_click("imVision System Manager Setup", "[NAME:buttonNext]")
         autoit.win_wait_active("Confirm")
         autoit.control_focus("Confirm", "[CLASS:Button; INSTANCE:1]")
         autoit.control_click("Confirm", "[CLASS:Button; INSTANCE:1]")
         autoit.win_wait_close("imVision System Manager Setup",timeout=600)
         shutil.rmtree("C:/Program Files/CommScope",True)
Exemple #16
0
 def test_video_file_upload(self):
     drive = GoogleDrivePage(self.driver)
     drive.click_new_button()
     drive.file_upload()
     time.sleep(5)
     autoit.control_focus("Open", "")
     time.sleep(20)
     autoit.control_set_text("Open", "Edit1",
                             "C:\\Users\\Dell\\Videos\\video1.mp4")
     time.sleep(10)
     autoit.control_click("Open", "Button1")
     time.sleep(5)
     print("Media file with extension .mp4 should be added to  my drive.")
Exemple #17
0
 def click(self, control: str, *, timeout=15, focus=True):
     timer = Timer(timeout)
     while timer.not_expired:
         try:
             if focus:
                 autoit.control_focus(self.title, control)
             autoit.control_click(self.title, control)
             return 0
         except Exception as e:
             # print(f"[Exception]--> {e}")
             pass
     if timer.expired:
         return -1
Exemple #18
0
def send_attachment():
    # Attachment Drop Down Menu
    clipButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/div/span')
    clipButton.click()
    time.sleep(1)

    # To send Videos and Images.
    mediaButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button'
    )
    mediaButton.click()
    time.sleep(3)

    hour = datetime.datetime.now().hour

    # After 5am and before 11am scheduled this.
    if (hour >= 5 and hour <= 11):
        image_path = os.path.join(os.getcwd(), "Media", "goodmorning.jpg")
    # After 9pm and before 11pm schedule this
    elif (hour >= 21 and hour <= 23):
        image_path = os.path.join(os.getcwd(), "Media", "goodnight.jpg")
    else:  # At any other time schedule this.
        image_path = os.path.join(os.getcwd(), "Media", "howareyou.jpg")

    if "autoit" in sys.modules:
        autoit.control_focus("Open", "Edit1")
        autoit.control_set_text("Open", "Edit1", (image_path))
        autoit.control_click("Open", "Button1")
    elif "applescript" in sys.modules:
        applescript.tell.app("System Events",
                             'keystroke "G" using {command down, shift down}')
        applescript.tell.app("System Events", "delay 1")
        applescript.tell.app("System Events", 'keystroke "' + image_path + '"')
        applescript.tell.app("System Events", "delay 1")
        applescript.tell.app("System Events", "keystroke return")

        applescript.tell.app("System Events", "delay 1")
        applescript.tell.app("System Events", "keystroke return")

        applescript.tell.app("System Events", "delay 1")
    else:
        print("Sending attachments is not supported on your system")
        return

    time.sleep(3)
    whatsapp_send_button = browser.find_element_by_xpath(
        '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span'
    )
    whatsapp_send_button.click()
Exemple #19
0
 def test_word_file_upload(self):
     drive = GoogleDrivePage(self.driver)
     drive.click_new_button()
     time.sleep(5)
     drive.file_upload()
     time.sleep(5)
     autoit.control_focus("Open", "")
     time.sleep(15)
     autoit.control_set_text("Open", "Edit1",
                             "C:\\Users\\Dell\\Desktop\\Gsuite.docx")
     time.sleep(10)
     autoit.control_click("Open", "Button1")
     time.sleep(3)
     print("A Non-google file is added to My drive")
Exemple #20
0
def send_image(image_path):
    find_by_xpath_click('//*[@id="main"]/header/div[3]/div/div[2]/div')
    find_by_xpath_click('//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button')
    
    while True:
        try:
            autoit.control_focus("Open","Edit1")
            autoit.control_set_text("Open","Edit1",(image_path) )
            autoit.control_click("Open","Button1")
            break
        except:
            sleep(random.randrange(1,3))

    find_by_xpath_click('//*[@id="app"]/div/div/div[1]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span')
Exemple #21
0
 def test_image_file_upload(self):
     drive = GoogleDrivePage(self.driver)
     drive.click_new_button()
     time.sleep(5)
     drive.file_upload()
     time.sleep(5)
     autoit.control_focus("Open", "")
     time.sleep(15)
     autoit.control_set_text("Open", "Edit1",
                             "C:\\Users\\Dell\\Pictures\\google.jpg")
     time.sleep(10)
     autoit.control_click("Open", "Button1")
     time.sleep(3)
     print("Media file with extension .jpg should be added to  my drive.")
Exemple #22
0
 def test_Login_to_Google_Doc(self):
     drive = GoogleDrivePage(self.driver)
     time.sleep(2)
     drive.click_new_button()
     drive.click_google_doc()
     print("welcome to Google Doc")
     self.driver.switch_to.window(self.driver.window_handles[2])
     googledoc = DocHomePage(self.driver)
     googledoc.click_on_title()
     act = ActionChains(self.driver)
     act.send_keys(Keys.BACKSPACE).perform()
     googledoc.document_title("Automation Doc Experimet")
     act.send_keys(Keys.ENTER).perform()
     googledoc.click_on_insert()
     time.sleep(3)
     act.send_keys(
         (Keys.ARROW_DOWN, Keys.ARROW_RIGHT, Keys.ENTER)).perform()
     time.sleep(5)
     autoit.control_focus("Open", "")
     time.sleep(10)
     autoit.control_set_text("Open", "Edit1",
                             "C:\\Users\\Dell\\Pictures\\google.jpg")
     time.sleep(10)
     autoit.control_click("Open", "Button1")
     time.sleep(5)
     googledoc.click_on_insert()
     time.sleep(2)
     act1 = ActionChains(self.driver)
     act1.send_keys((Keys.ARROW_DOWN, Keys.ARROW_DOWN, Keys.ARROW_RIGHT,
                     Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, Keys.ARROW_DOWN,
                     Keys.ARROW_DOWN, Keys.ENTER)).perform()
     act1.send_keys(Keys.PAGE_DOWN, Keys.ENTER).perform()
     time.sleep(5)
     googledoc.click_on_insert()
     time.sleep(5)
     act2 = ActionChains(self.driver)
     act2.send_keys((Keys.ARROW_DOWN, Keys.ARROW_DOWN, Keys.ARROW_DOWN,
                     Keys.ARROW_DOWN, Keys.ARROW_RIGHT, Keys.ARROW_DOWN,
                     Keys.ENTER)).perform()
     time.sleep(5)
     act2.send_keys(Keys.PAGE_DOWN, Keys.ENTER).perform()
     act2.send_keys(
         "Google, LLC is an American multinational technology company that specializes in "
         "Internet-related services and products, which include online advertising technologies, "
         "a search engine, cloud computing, software, and hardware. "
     ).perform()
     time.sleep(10)
     print(
         "A google doc is created in your My drive with following content - 01 image, 01 table (3X3), 01 chart, "
         "01 drawing, 01 paragrah of 100-400 characters")
Exemple #23
0
 def get_text(self, control: str, *, timeout=15, focus=True):
     ctrl_txt = None
     timer = Timer(timeout)
     while timer.not_expired:
         try:
             if focus:
                 autoit.control_focus(self.title, control)
             ctrl_txt = autoit.control_get_text(self.title, control)
             if isinstance(ctrl_txt, str):
                 return ctrl_txt
         except Exception as e:
             # print(f"[Exception]--> {e}")
             pass
     if timer.expired:
         return -1
Exemple #24
0
def send_files():
    global doc_filename
    # Attachment Drop Down Menu
    clipButton = browser.find_element_by_xpath(
        '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div/div/span')
    clipButton.click()

    time.sleep(1)
    # To send a Document(PDF, Word file, PPT)
    # This makes sure that gifs, images can be imported through documents folder and they display
    # properly in whatsapp web.
    if doc_filename.split('.')[1] == 'pdf' or doc_filename.split(
            '.')[1] == 'docx' or doc_filename.split('.')[1] == 'pptx':
        try:
            docButton = browser.find_element_by_xpath(
                '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div/span/div/div/ul/li[3]/button'
            )

            docButton.click()
        except:
            # Check for traceback errors with XML imports
            traceback.print_exc()
    else:
        try:
            # IMG attatchment button
            docButton = browser.find_element_by_xpath(
                '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div/span/div/div/ul/li[1]/button'
            )
            docButton.click()
        except:
            # Check for traceback errors with XML imports
            traceback.print_exc()
    time.sleep(1)
    docPath = os.getcwd() + "\\Documents\\" + doc_filename
    try:
        autoit.control_focus("Open", "Edit1")
    except:
        traceback.print_exc()
    autoit.control_set_text("Open", "Edit1", (docPath))
    autoit.control_click("Open", "Button1")
    time.sleep(3)
    # Changed whatsapp send button xml link.
    whatsapp_send_button = browser.find_element_by_xpath(
        '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span/div/div'
    )

    whatsapp_send_button.click()
    print('File sent')
Exemple #25
0
def Cliente(Tipo, Cod):
    log.EscreverLog('Função Cliente ')
    #Tempo.TempoL()
    #if(autoit.win_wait("[CLASS:TFRM_FINALVENDA]"))==1:
    Variaveis.Retorno = 0
    while Variaveis.Retorno == 0:
        Variaveis.Retorno = autoit.control_focus("[CLASS:TFRM_FINALVENDA]",
                                                 "TRzDBButtonEdit6")
        Tempo.Loop()
    #else:
    #    Tempo.TempoL()
    try:
        #Tempo.TempoL()
        autoit.control_send("[CLASS:TFRM_FINALVENDA]", "TRzDBButtonEdit6",
                            str(Cod))
        Tempo.Dig()
        log.EscreverLog('Passamdo codigo do Cliente:' + str(Cod))
        for x in range(0, 2):
            Tecla.Enter()
        if Tipo == "TP" or Tipo == "TC":
            if Tipo == "P":
                SENHACLIBLOQ.SENHACLIBLOQ()
            if Tipo == "C":
                time.sleep(Variaveis.TConvenio)
                SENHAEMPBLOQ.SENHAEMPBLOQ()
                SENHACLIBLOQ.SENHACLIBLOQ()
                SENHALIMITECREDITO.SENHALIMITECREDITO()
    except:
        log.EscreverLog('Erro Função Cliente')

    log.EscreverLog('Sai Função Cliente')
def post_ig():
	mobile_emulation = { "deviceName": "Nexus 5" }
	options = webdriver.ChromeOptions()
	options.add_experimental_option("mobileEmulation", mobile_emulation)
	driver = webdriver.Chrome(chrome_options=options)
	driver.get('https://www.instagram.com/')
	time.sleep(3)
	driver.find_element_by_xpath('/html[1]/body[1]/div[1]/section[1]/main[1]/article[1]/div[1]/div[1]/div[1]/div[2]/button[1]').click()
	time.sleep(4)
	pass_field = driver.find_element_by_xpath("//input[@name='password']")
	pass_field.click()
	pass_field.send_keys('helloitsme123')
	time.sleep(2)
	user_field = driver.find_element_by_xpath("//input[@name='username']")
	user_field.send_keys('track_covid')
	time.sleep(2)
	driver.find_element_by_xpath("/html[1]/body[1]/div[1]/section[1]/main[1]/article[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[6]/button[1]").click()
	time.sleep(5)
	driver.find_element_by_xpath("//button[contains(text(),'Not Now')]").click()
	time.sleep(3)
	driver.find_element_by_xpath("//button[contains(text(),'Cancel')]").click()
	time.sleep(2)
	driver.find_element_by_xpath("//div[@class='q02Nz _0TPg']//*[local-name()='svg']").click()
	time.sleep(2)
	autoit.control_focus("Open","Edit1")
	autoit.control_set_text("Open","Edit1",'E:\Summer Proj\Covid_Tracker\Code\My_Map_I.png' )
	autoit.control_click("Open","Button1")
	time.sleep(2)
	driver.find_element_by_xpath("//button[@class='UP43G']").click()
	time.sleep(2)
	Caption = driver.find_element_by_xpath("//textarea[@placeholder='Write a caption…']")
	Caption.send_keys('Follow @track_covid for latest updates on the Covid 19 Pandemic. This is an automated software which automatically fetches the data from mohfw.gov.in and edits the photo accordingly. Stay Home, Stay Safe! ')
	time.sleep(2)
	driver.find_element_by_xpath("//button[@class='UP43G']").click()
	time.sleep(6)
	driver.find_element_by_xpath("//button[contains(text(),'Not Now')]").click()
	time.sleep(2)
	driver.find_element_by_xpath("//a[contains(@class,'gKAyB')]//img[@class='_6q-tv']").click()
	time.sleep(3)
	driver.find_element_by_xpath("//div[@class='_9AhH0']").click()
	time.sleep(2)
	driver.find_element_by_xpath("//span[@class='_15y0l']//button[contains(@class,'wpO6b')]//*[local-name()='svg']").click()
	time.sleep(3)
	mess = driver.find_element_by_xpath("//textarea[@placeholder='Add a comment…']")
	mess.send_keys('#stayhomesavelives #coronavirus #covid19 #covid #love #instagood #photooftheday #fashion #beautiful #happy #cute #like4like #follow #me #art #instadaily #friends #repost #nature #girl #fun #style #food #intensivecare #wearecritical #covidindia #covidinfo #covidart #covidfreestylechallenge #covidphotodiaries')
	driver.find_element_by_xpath("//button[contains(text(),'Post')]").click()
	driver.quit()
Exemple #27
0
def send_attachment(docType):
    if docType == 1:
        medialist = read_database(wb_name, campaign, 'D')
        medialist_Desc = read_database(wb_name, campaign, 'E')
    else:
        medialist = read_database(wb_name, campaign, 'G')
    
    image_path = read_medialist(medialist, docType)
    print(medialist[1:])    

    clipButton = browser.find_element_by_xpath('//*[@id="main"]/footer/div[1]/div[1]/div[2]/div')
    clipButton.click()

    time.sleep(5)
    if docType == 1:
        address_XPATH = '//*[@id="main"]/footer/div[1]/div[1]/div[2]/span/div/div/ul/li[1]/button'
        mediaButton = browser.find_element_by_xpath(address_XPATH)
        mediaButton.click()
    else:
        address_XPATH = '//*[@id="main"]/footer/div[1]/div[1]/div[2]/span/div/div/ul/li[3]/button'
        docButton = browser.find_element_by_xpath(address_XPATH)
        docButton.click()
    autoitloading(autoit)
    time.sleep(1)
    autoit.control_focus("Open", "Edit1")
    autoit.control_set_text("Open", "Edit1", image_path)
    autoit.control_click("Open", "Button1")
    
    if docType == 1:
        time.sleep(5)
        address_XPATH = '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/div[1]/span/div/div[2]/div/div[3]/div[1]'
        ket = browser.find_element_by_xpath(address_XPATH)   
        ket.send_keys(medialist_Desc[0])

        a = image_path.split(' ')

        for i in range(len(a)-2):
            imPress = browser.find_element_by_xpath('//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/div[2]/span/div[' + str(i+2)+ ']')
            imPress.click()

            ket = browser.find_element_by_xpath('//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/div[1]/span/div/div[2]/div/div[3]/div[1]')   
            ket.send_keys(medialist_Desc[i+1])


    time.sleep(5)
    whatsapp_send_button = browser.find_element_by_xpath('//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span/div')
    whatsapp_send_button.click()
Exemple #28
0
def uploadImage(driver, imageId, imageUrl, log):
    printLog(log)
    # item = getItemByIdUntilTimeout(browser,imageId,4)# open image upload dialog
    # item.click()
    driver.find_element_by_xpath(imageId).click()  # open image upload dialog
    autoit.win_wait_active("Open")
    autoit.control_focus(config["uploadFileTitleName"],
                         "[CLASS:Edit; INSTANCE:1]")
    time.sleep(0.5)
    autoit.control_set_text(config["uploadFileTitleName"],
                            "[CLASS:Edit; INSTANCE:1]", imageUrl)
    # autoit.clip_put(imageUrl)
    # autoit.send("^v")
    time.sleep(float(config["uploadImageDelayTime"]))
    autoit.control_click("Open", "[CLASS:Button; INSTANCE:1]")
    time.sleep(1)
    autoit.win_wait_close("Open")
Exemple #29
0
def whatsAppSendFile(fileName):
    try:
        # Attachment drop down menu.
        writeConsole("Attaching ...")
        if (domWaitForElementClick('//*[@id="main"]/footer/div[1]/div[1]/div[2]/div/div/span') == False):
            writeConsole("Failed to attach file.")
            return False

        time.sleep(1)

        # Attach file and document.
        writeConsole("Attaching file ...")
        if (domWaitForElementClick('//*[@id="main"]/footer/div[1]/div[1]/div[2]/div/span/div/div/ul/li[3]/button') == False):
            writeConsole("Failed to attach file.")
            return False

        time.sleep(1)

        # Selecting file
        image_path = resolveFilePath(fileName, WorkFolder)
        autoit.control_focus("Open", "Edit1")
        autoit.control_set_text("Open", "Edit1", (image_path))
        autoit.control_click("Open", "Button1")

        time.sleep(2)

        # Clicking send
        writeConsole("Sending ...")
        if (domWaitForElementClick('//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span') == False):
            writeConsole("Failed to attach file.")
            return False

        time.sleep(2)

        # Waiting for upload
        writeConsole("Waiting for upload ...")
        if (whatsAppWaitForDelivery() == False):
            writeConsole("Failed to attach file.")
            return False

        writeConsole("Sent.")
        return True
    except:
        writeConsole("Failed to attach file.")
        return False
Exemple #30
0
def sendMedia(filename):  #onlyForWindows
    clipButton = driver.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/div/span')
    clipButton.click()
    time.sleep(1)
    mediaButton = driver.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button'
    )
    mediaButton.click()
    image = os.getcwd() + "\\Media\\" + filename
    autoit.control_focus("Open", "Edit1")
    autoit.control_set_text("Open", "Edit1", image)
    autoit.control_click("Open", "Button1")
    time.sleep(3)
    sendButton = driver.find_element_by_xpath(
        '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span'
    )
    sendButton.click()
Exemple #31
0
    def add_photo(image_path):
        """
        Метод добавляет фото по указанному пути
        :param image_path: - абсолютный путь до фото
        :return:
        """
        import autoit

        title = "[CLASS:#32770]"
        control = '[CLASS:Edit; INSTANCE:1]'
        control_open_btn = '[CLASS:Button; INSTANCE:1]'
        opened = autoit.win_wait(title, 5)
        if opened != 1:
            msg = "Not opened window!"
            service_log.error(msg)
            assert msg
        handle = autoit.win_get_handle(title)
        if isinstance(handle, int) is not True:
            msg = "Not found Handle!"
            service_log.error(msg)
            assert msg
        autoit.win_activate_by_handle(handle)
        ret = autoit.control_focus(title, control)
        if ret != 1:
            msg = "Not found control_focus!"
            service_log.error(msg)
            assert msg
        time.sleep(1)
        autoit.control_set_text(title, control, image_path)
        autoit.control_focus(title, control_open_btn)
        autoit.control_click(title, control_open_btn)
        #autoit.mouse_click()
        #ENTER - подтверждение (можно вместо этого нажать на кнопку)
        #autoit.send("{ENTER}")
        time.sleep(5)
        return True