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')
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()
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() # 关闭浏览器
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()
return False # the id you want to check goods_id = "00718624969" # family url 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