Esempio n. 1
0
def login_connpass():
    """connpassにログインする(ユーザー名とパスワードは環境変数を想定)"""
    go_to("connpass.com/login")
    write(os.getenv("CONNPASS_USERNAME"), into="ユーザー名")
    write(os.getenv("CONNPASS_PASSWORD"), into="パスワード")
    click("ログインする")

    wait_until(Text("あなたのイベント").exists)
Esempio n. 2
0
 def test_switch_to_search_text_field(self):
     write("Main window", into="Text field")
     self.assertEqual("Main window", TextField("Text field").value)
     self._open_popup()
     write("Popup", into="Text field")
     self.assertEqual("Popup", TextField("Text field").value)
     switch_to("test_window_handling - Main")
     self.assertEqual("Main window", TextField("Text field").value)
Esempio n. 3
0
 def test_invalid_credentials(self):
     driver = helium.start_chrome('https://goantifraud.com/manager',
                                  headless=True)
     helium.write(TEST_DATA['invalid_credentials']['log'], into='login')
     helium.write(TEST_DATA['invalid_credentials']['pass'], into='password')
     helium.press(helium.ENTER)
     check = helium.Text('Login or password is incorrect').value
     helium.kill_browser()
     self.assertEqual(check, 'Login or password is incorrect')
Esempio n. 4
0
 def join_school(self):
     #!!!!!NOT TESTED YET!!!!!!
     self.driver.get(
         "https://www.kartable.fr/classe?navigationOrigin=ruby-quest")
     helium.write(self.ecole, into="Rechercher un établissement...")
     select = Select(self.driver.find_element_by_tag_name('select'))
     select.select_by_value('1')  # select the first
     helium.click("rejoindre")
     self.driver.find_element_by_class_name("icon-close").click()
Esempio n. 5
0
 def test_recover_pass_with_invalid_user(self):
     driver = helium.start_chrome('https://goantifraud.com/manager',
                                  headless=True)
     helium.click('Forgot your password?')
     helium.write(TEST_DATA['invalid_credentials']['log'], into='login')
     helium.click('SEND')
     time.sleep(0.5)
     validation_msg_list = helium.find_all(helium.S(".error.error_show"))
     helium.kill_browser()
     self.assertEqual(len(validation_msg_list), 2)
Esempio n. 6
0
    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        keyword = tracker.get_slot('keyword')
        if keyword:
            write(keyword)
            tracker.slots = {'keyword': ''}
            dispatcher.utter_message("已输入")

        else:
            dispatcher.utter_message("抱歉,无法识别关键词名称")
        return []
Esempio n. 7
0
def submit_request(song,
                   artist,
                   url='www.harmonixmusic.com/games/rock-band/request'):
    "Uses helium framework to open chrome, open a website, and submit a song"

    logging.info("Logging into %s", url)
    start_chrome(url, headless=True)
    write(song, into='Song Title')
    write(artist, into='Artist')
    logging.info("Submitting request for '%s' by '%s'", song, artist)
    click('Submit')
    kill_browser()
Esempio n. 8
0
def main(dict_classes, schedule_sheet, hours_list, cells_list, days_list,
         credentials):
    take()
    start_chrome("google.com")
    # login into the Google account
    if credentials[0] == "ita\n":
        go_to(
            "https://accounts.google.com/signin/v2/identifier?service=classroom&passive=1209600&continue=https%3A%2F%2Fclassroom.google.com%2Fu%2F0%2Fh%3Fhl%3Dit&followup=https%3A%2F%2Fclassroom.google.com%2Fu%2F0%2Fh%3Fhl%3Dit&hl=it&flowName=GlifWebSignIn&flowEntry=ServiceLogin"
        )
        write(
            credentials[1].replace("\n", ""),
            into="Indirizzo email o numero di telefono",
        )
        press(ENTER)
        write(credentials[2], into="Inserisci la password")
        press(ENTER)
    elif credentials[0] == "eng\n,":
        go_to(
            "https://accounts.google.com/signin/v2/identifier?service=classroom&passive=1209600&continue=https%3A%2F%2Fclassroom.google.com%2Fu%2F0%2Fh%3Fhl%3Dit&followup=https%3A%2F%2Fclassroom.google.com%2Fu%2F0%2Fh%3Fhl%3Dit&hl=it&flowName=GlifWebSignIn&flowEntry=ServiceLogin"
        )
        write(credentials[1].replace("\n", ""), into="Email or phone")
        press(ENTER)
        write(credentials[2], into="Enter your password")
        press(ENTER)
    else:
        print(colorama.Fore.RED + colorama.Style.BRIGHT +
              "\n\nThe language is not supported (ita-eng)")
    while A == 0:
        k = giorno(days_list)
        materia = ora(hours_list, cells_list, k, schedule_sheet)
        meet(materia, dict_classes, k, credentials)
Esempio n. 9
0
def getDemons(name):
    list1 = []
    list0 = []
    start_chrome('https://pointercrate.com/demonlist/')
    press(END)
    press(PAGE_UP)
    click('Open the stats viewer!')
    write(name, into='Enter to search...')
    click(name)
    time.sleep(1)
    main_is_empty = 1
    extended_is_empty = 1
    mainverifs_is_empty = 1
    extendedverifs_is_empty = 1
    for x in range(75):
        counter = x + 1
        if main_is_empty:
            mainlist = find_all(S('//*[@id="beaten"]/b[%d]/a' % (counter)))
        if extended_is_empty:
            extendedlist = find_all(
                S('//*[@id="beaten"]/span[%d]/a' % (counter)))
        if mainverifs_is_empty:
            verifications_main = find_all(
                S('//*[@id="verified"]/b[%d]/a' % (counter)))
        if extendedverifs_is_empty:
            verifications_extended = find_all(
                S('//*[@id="verified"]/span[%d]/a' % (counter)))
        if mainlist == []:
            main_is_empty = 0
        if extendedlist == []:
            extended_is_empty = 0
        if verifications_main == []:
            mainverifs_is_empty = 0
        if verifications_extended == []:
            extendedverifs_is_empty = 0
        list0.append(mainlist)
        list0.append(extendedlist)
        list0.append(verifications_main)
        list0.append(verifications_extended)
    list0 = [element for element in list0 if element != []]
    for demon in list0:
        demon = str(demon)
        start = [m.start() for m in re.finditer(">", demon)][0]
        end = [m.start() for m in re.finditer("<", demon)][1]
        demon = demon[(start + 1):end]
        list1.append(demon)
    kill_browser()
    return list1
Esempio n. 10
0
def balance_kasbon(mode, project=None):

    wait('Report Balancing')
    click('Edit')

    for n in range(len(driver.find_elements_by_name('to_pay'))):

        if (mode == GROSSUP or mode == LABOUR) and (project[0] != 'K'):
            driver.find_elements_by_css_selector("td:nth-child(4)")[n].click()
            sleep(1.5)
            write('6100-010')
            sleep(1.5)
            press(Keys.ENTER)

        driver.find_elements_by_css_selector("td:nth-child(9)")[n].click()
        sleep(1.5)
        write(driver.find_elements_by_name('to_pay')[n].text)

    if (mode != BALANCE_RECEIVABLE and
        mode != BALANCE_PAYABLE and
        mode != BALANCE):
        click('Save')

    wait('Edit')

    click('Report Balancing')
    wait('Kasbon Progress')
    entry(DATE)
    click('OK')

    wait('Post Balance')
    click('Post Balance')
    wait('Kasbon Progress')
    entry(DATE)
    entry(BANK)

    if (mode == BALANCE_RECEIVABLE):
        entry(DIFF_ACCOUNT,'1150-999')
    elif (mode == BALANCE_PAYABLE):
        entry(DIFF_ACCOUNT,'2170-009')
    elif (mode == BALANCE):
        try:
            entry(DIFF_ACCOUNT,'1112-101')
        except:
            pass

    click('OK')
Esempio n. 11
0
	def test_interact_with_found_elements(self):
		all_tfs = find_all(TextField())
		example_tf = None
		for text_field in all_tfs:
			try:
				id_ = text_field.web_element.get_attribute('id')
			except StaleElementReferenceException:
				# This may happen for found web elements in different iframes.
				# TODO: Improve this, eg. by adding a .getId() property to
				# TextField (/HTMLElement) which handles this problem.
				pass
			else:
				if id_ == 'exampleTextFieldId':
					example_tf = text_field
		self.assertIsNotNone(example_tf)
		write("test_interact_with_found_elements", into=example_tf)
		self.assertEqual(
			"test_interact_with_found_elements",
			TextField("Example Text Field").value
		)
Esempio n. 12
0
 def change_password(self, new_password):
     #!!!!!NOT TESTED YET!!!!!!
     # https://www.kartable.fr/compte/informations-personnelles/modifier-mot-de-passe
     helium.write(self.password, into="Mot de passe actuel")
     helium.write(new_password, into="Nouveau mot de passe")
     helium.write(new_password, into="Ressaisir nouveau mot de passe")
     helium.click("mettre à jour")
Esempio n. 13
0
 def register(self, sponso=False):
     if sponso == False:
         try:
             helium.click("élève")
             helium.click("élève")
         except LookupError:
             print("élève failed")
     helium.click(self.classe)
     helium.click("s'inscrire avec un e-mail")
     helium.write(self.firstname, into="prénom")
     helium.write(self.lastname, into="nom")
     helium.write(self.email, into="adresse e-mail")
     helium.write(self.password, into="mot de passe")
     # Setting custom birthdate
     self.set_birthdate()
     helium.click("terminer")
     # time.sleep(5)
     try:
         helium.click("plus tard")
     except LookupError:
         pass
     time.sleep(5)
Esempio n. 14
0
	def test_write_into(self):
		write("Hi there!", into='Normal text field')
		self.assertEqual("Hi there!", TextField('Normal text field').value)
Esempio n. 15
0
 def change_email(self, new_email):
     #!!!!!NOT TESTED YET!!!!!!
     # https://www.kartable.fr/compte/informations-personnelles/modifier-adresse-email
     for i in self.driver.find_element_by_tag_name("input"):
         helium.write(new_email, into=i)
     helium.click("mettre à jour")
Esempio n. 16
0
 def test_write_into_non_existent_label_raises_exception(self):
     with self.assertRaises(UnexpectedAlertPresentException) as cm:
         write("5", into="Please enter a value")
     msg = self._get_unhandled_alert_exception_msg(cm.exception)
     self.assertEqual(self.UNEXPECTED_ALERT_PRESENT_EXCEPTION_MSG, msg)
Esempio n. 17
0
 def log_in(self):
     self.driver.get("https://www.kartable.fr/connexion")
     helium.write(self.email, into="adresse e-mail")
     helium.write(self.password, into="mot de passe")
     helium.click("se connecter")
Esempio n. 18
0
family = "https://www.famiport.com.tw/Web_Famiport/page/process.aspx"

# init browser
options = FirefoxOptions()
options.add_argument("--width=800")
options.add_argument("--height=800")
driver = helium.start_firefox(family, options=options)

# wait until web completely loaded
helium.wait_until(helium.Text("※請輸入驗證碼。").exists)

# find all textfield
textfields = helium.find_all(helium.TextField())

# write to the fisrt goods
helium.write(goods_id, into=textfields[2])

# scroll down for viewing verification code and take screenshot
helium.scroll_down(500)
driver.save_screenshot("temp.png")

# read from screen shot as gray image
img = cv2.imread("temp.png", cv2.IMREAD_GRAYSCALE)

# convert to only black and white
ret, img = cv2.threshold(img, 175, 255, cv2.THRESH_BINARY_INV)

# for debug
img_color = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)

# find all contours
from contextlib import contextmanager

from helium import (
    Text,
    click,
    go_to,
    kill_browser,
    start_firefox,
    wait_until,
    write,
)


@contextmanager
def using_firefox():
    start_firefox()
    try:
        yield
    finally:
        kill_browser()


if __name__ == "__main__":
    with using_firefox():
        go_to("connpass.com/login")
        write(os.getenv("CONNPASS_USERNAME"), into="ユーザー名")
        write(os.getenv("CONNPASS_PASSWORD"), into="パスワード")
        click("ログインする")

        wait_until(Text("あなたのイベント").exists)
Esempio n. 20
0
 def test_write_into_text_field_raises_exception(self):
     with self.assertRaises(UnexpectedAlertPresentException) as cm:
         write("4", into=TextField("Please enter a value"))
     msg = self._get_unhandled_alert_exception_msg(cm.exception)
     self.assertEqual(self.UNEXPECTED_ALERT_PRESENT_EXCEPTION_MSG, msg)
 def test_write_into_labelled_text_field(self):
     write('Some text', into='Labelled Text Field')
     self.assertEqual('Some text', TextField('Labelled Text Field').value)
import helium
# 比较适合新手的自动化库
from time import sleep

home_url = 'https://mail.163.com/'  # 网站主地址
user_name = 'luobomc'  # 登陆用户名
password = '******'  # 密码

driver = helium.start_chrome(home_url)  # 打开浏览器 并且打开home_url地址页面
sleep(5)  # 睡眠5s等待页面加载
helium.write(user_name,
             helium.TextField('邮箱帐号或手机号码'))  # 锁定'邮箱账号或手机号码'并且锁定 然后传入用户名
sleep(2)  # 睡眠2秒
helium.write(password, helium.TextField('输入密码'))  # 锁定密码输入框并且输入
helium.press(helium.ENTER)  # 模拟按回车 登录
sleep(5)  # 睡眠5秒等待页面刷新
helium.click(helium.Text('收 信'))  # 点击收信按钮 查看邮件
helium.kill_browser()  # 关闭浏览器
Esempio n. 23
0
 def test_write_into_alert(self):
     write("7", into=Alert())
     Alert().accept()
     self._expect_result("Value entered: 7")
Esempio n. 24
0
def connect_to_local_runtime(user_choice): 

    try:
        # import chromedriver_binary
        if user_choice == "ClointFusion Labs (Public)":
            colab_url = "https://accounts.google.com/signin/v2/identifier?authuser=0&hl=en&continue=https://colab.research.google.com/github/ClointFusion/ClointFusion/blob/master/ClointFusion_Labs.ipynb" #https://colab.research.google.com/github/ClointFusion/ClointFusion/blob/master/ClointFusion_Labs.ipynb"
            # colab_url = "https://colab.research.google.com/github/ClointFusion/ClointFusion/blob/master/ClointFusion_Labs.ipynb"
                        
        # elif user_choice == "ClointFusion Lite (Interns Only)":
        #     #Extract encrypted version of ClointFusion_Lite to a specific folder and in Colab import that folder
        #     colab_url = 'https://accounts.google.com/signin/v2/identifier?authuser=0&hl=en&continue=https://colab.research.google.com/drive/11MvoQfNFXJqlXKcXV1LBVUE98Ks48M_a'

        elif user_choice == "ClointFusion Starter (Hackathon)":        
            colab_url = 'https://accounts.google.com/signin/v2/identifier?authuser=0&hl=en&continue=https://colab.research.google.com/drive/1G9mh58z8AbWqBit2TC4Wgg6p_eHPvUJB'

        user_data_path = "C:\\Users\\{}\\AppData\\Local\\Google\\Chrome\\User Data".format(os.getlogin())

        modify_file_as_text(user_data_path + '\\Default\\Preferences', 'crashed', 'false')

        options = Options()
        options.add_argument("--start-maximized")
        options.add_experimental_option('excludeSwitches', ['enable-logging'])
        
        if os_name == "windows":
            options.add_argument("user-data-dir=C:\\Users\\{}\\AppData\\Local\\Google\\Chrome\\User Data".format(os.getlogin()))
        elif os_name == "darwin":
            options.add_argument("user-data-dir=/Users/{}/Library/Application/Support/Google/Chrome/User Data".format(os.getlogin()))
        options.add_argument(f"profile-directory=Default")
        
        browser_driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
        browser.set_driver(browser_driver)
        browser.go_to(colab_url)

        chrome = gw.getWindowsWithTitle('Google Chrome')[0]
        chrome.activate()

        # pg.doubleClick(pg.size()[0]/2,pg.size()[1]/2)
        # kb.press_and_release('esc')
        # kb.press_and_release('esc')

        try:
            browser.wait_until(browser.Text("Code").exists,timeout_secs=6)
            
        except :#selenium_wrappers.common.exceptions.TimeoutException:
            try:
                browser.click(email)
            except:
                browser.write(email, into='Email or phone')

            browser.click('Next')
            time.sleep(0.5)

            browser.write(passwd, into='Enter your password')
            browser.click('Next')
            time.sleep(0.5)

            browser.wait_until(browser.Text("Code").exists,timeout_secs=240)

        # kb.press_and_release('esc')
        # time.sleep(0.2)

        # pg.press(ESCAPE)
        # time.sleep(0.2)

        # press(ESCAPE)
        # time.sleep(0.2)

        if FIRST_TIME:
            #create short-cut
            browser.press(browser.CONTROL + 'mh')
            time.sleep(1)

            v = S("//input[@id='pref_shortcut_connectLocal']")

            browser.write('',v)

            browser.press(browser.CONTROL + '1')
            time.sleep(0.5)
            
            browser.click("SAVE")

            time.sleep(1)

        #use short-cut

        browser.press(browser.CONTROL + '1')
        time.sleep(1)
        # pg.alert("HKHR")

        pg.doubleClick(pg.size()[0]/2,pg.size()[1]/2)
        time.sleep(1)

        if FIRST_TIME:
            
            
            # kb.press_and_release('SHIFT+TAB')
            pg.hotkey('SHIFT', 'TAB')
            time.sleep(0.5)
            # kb.press_and_release('SHIFT+TAB')
            pg.hotkey('SHIFT', 'TAB')
            time.sleep(0.5)
            # kb.press_and_release('SHIFT+TAB')
            pg.hotkey('SHIFT', 'TAB')
            time.sleep(0.5)
            pg.write("http://localhost:8888")
            # kb.write("http://localhost:8888")
            time.sleep(2)

        # click("CONNECT")
            # kb.press_and_release('TAB')
            pg.hotkey('TAB')
            
            time.sleep(0.5)
            # pg.alert(1)
            # kb.press_and_release('TAB')
            pg.hotkey('TAB')
            time.sleep(0.5)
            # pg.alert(2)

        else:
            # kb.press_and_release('SHIFT+TAB')
            pg.hotkey('SHIFT', 'TAB')
            time.sleep(0.5)

        browser.press(browser.ENTER)
        time.sleep(2)

        # try:
        #     img = "Restore_Bubble.PNG"
        #     pos = pg.locateOnScreen(img, confidence=0.8)  #region=
        #     pg.alert(pos)
        #     pg.click(*pos)
        # except:
        #     pass

        pg.alert("Ready ! Google Colab is now connected with your Local Runtime.\n\nPlease click 'OK' & you are all set to work on ClointFusion Colabs...")

    except Exception as ex:
        print("Error in connect_to_local_runtime="+str(ex))
        exc_type, exc_value, exc_tb = sys.exc_info()
        pg.alert(traceback.format_exception(exc_type, exc_value, exc_tb,limit=None, chain=True))

        pg.alert("Error in connect_to_local_runtime="+str(ex))
        connect_to_local_runtime()
Esempio n. 25
0
 def test_write_into_non_existent_alert(self):
     with TemporaryAttrValue(Config, 'implicit_wait_secs', 1):
         with self.assertRaises(LookupError):
             write("8", into=Alert("Non-existent"))
Esempio n. 26
0
 def test_write_into_labelled_alert(self):
     write("8", into=Alert(self.get_expected_alert_text()))
     Alert().accept()
     self._expect_result("Value entered: 8")
Esempio n. 27
0
import helium
import hashlib

driver = helium.start_chrome("https://temp-mail.org/en/", headless=True)
helium.wait_until(
    lambda: "@" in helium.TextField("Your Temporary email address").value)
email = helium.TextField("Your Temporary email address").value
password = hashlib.sha1(email.encode()).hexdigest()
print(email, password)
helium.kill_browser()
driver = helium.start_chrome("https://www.kartable.fr/inscription")
helium.click("élève")
helium.click("1ère")
helium.click("s'inscrire avec un e-mail")
helium.write("Cld", into="prénom")
helium.write("Lokidod", into="nom")
helium.write(email, into="adresse e-mail")
helium.write(password, into="mot de passe")
helium.click("terminer")
helium.wait_until(helium.Text("plus tard").exists)
helium.click("plus tard")
#helium.kill_browser()
Esempio n. 28
0
	def test_write_into_text_field_to_right_of(self):
		write("Hi there!", into=(TextField(to_right_of='Normal text field')))
		self.assertEqual("Hi there!", TextField('Normal text field').value)
Esempio n. 29
0
	def test_write(self):
		write("Hello World!")
		self.assertEqual(
			"Hello World!", TextField('Autofocus text field').value
		)
Esempio n. 30
0
 def test_write_searches_in_active_window(self):
     write("Main window", into="Text field")
     self.assertEqual("Main window", self._get_value('mainTextField'))
     self._open_popup()
     write("Popup", into="Text field")
     self.assertEqual("Popup", self._get_value('popupTextField'))