def Edge_driver(): # Login information for the activation manager Username = "******" Password = "******" #Serial number as entered in UI by user global serial #Get the serial as a string Serial = serial.get() #Load up an instance of Microsoft Edge and Open Activation Manager driver = Edge() driver.get("URL") #Login using credentials User_Element = driver.find_element_by_name("Login2:txtName") User_Element.send_keys(Username) Password_Element = driver.find_element_by_name("Login2:txtPassword") Password_Element.send_keys(Password) Login_Element = driver.find_element_by_name("Login2:cmdLogin") Login_Element.submit() #Enter Serial input from user Serial_Element = driver.find_element_by_name("txtSearch") Serial_Element.send_keys(Serial) #Submit form ### NOTE: sumbit() did not work, click() does. Need to understand difference. Submit_Element = driver.find_element_by_name("cmdLookup") Submit_Element.click()
def Restart_Modem(): options = EdgeOptions() options.use_chromium = True options.add_argument("-inprivate") edge_browser = Edge(options=options) edge_browser.get('http://192.168.0.1') time.sleep(2) print('Welcome') try: login = edge_browser.find_element_by_name('username') password = edge_browser.find_element_by_name('password') sign = edge_browser.find_element_by_class_name('styled_button_s') login.clear() password.clear() login.send_keys('admin') password.send_keys('admin') time.sleep(2) sign.click() print('Sign in') alert = Alert(edge_browser) time.sleep(2) edge_browser.get('http://192.168.0.1/saveconf.htm') time.sleep(2) system = edge_browser.find_element_by_id('three_level_menu1') system.click() time.sleep(2) reboot = edge_browser.find_element_by_name('reboot') reboot.click() alert.accept() time.sleep(70) print('Reboot') edge_browser.quit() except: print('Problem with restarting modem') edge_browser.quit()
def run(): email = read_decrypt(efile) password = read_decrypt(pfile) cemail = str(email) cpassword = str(password) print(cemail) print(cpassword) with open("browserdetails.txt", "r") as f: data = [line.rstrip('\n') for line in f] browser = data[0].lower() gpu = data[1].lower() if browser == 'edge': try: requests.get("http://www.google.com") print('Connection Found') options = EdgeOptions() options.use_chromium = True options.add_argument("--start-maximized") if gpu == 'no': options.add_argument("window-size=1920,1080") options.add_argument("--headless") options.add_argument("disable-gpu") options.add_argument("-inprivate") driver = Edge(executable_path='msedgedriver.exe', options=options) driver.get('https://gokano.com/') try: email = WebDriverWait(driver, 3).until( EC.presence_of_element_located((By.NAME, 'email'))) print("Page is ready!") email.send_keys(cemail) password = driver.find_element_by_name('password') password.send_keys(cpassword) time.sleep(3) button = driver.find_element_by_class_name('submit') button.click() print('Login sucessful') except TimeoutException: print("Error logining in") #[email protected] time.sleep(3) driver.quit() time.sleep(3) try: cdp = driver.find_element_by_link_text('Collect daily points') cdp.click() write_time() time.sleep(3) driver.quit() except NoSuchElementException: print('Already collected') time.sleep(3) driver.quit() print('Automation completed') time.sleep(3) driver.quit() except requests.ConnectionError: print('Could not connect')
def judith(SITE): driver = Edge(PATH) driver.get(SITE) #find the element by his name, it can be by its ID or CSS tho element = driver.find_element_by_name("objetos") element.clear() #insert the apropriate tracking code and then proceeds to the next page element.send_keys(CODE) element.send_keys(Keys.RETURN) #must implement total headless mode and print in terminal the state #it needs to go here #in this exact spot #save a screenshot of the tracking progress bc im lazy right now to implement a callback terminal function driver.save_screenshot('consulta.png') #if the code is wrong, it'll show this output assert "Sem bagulhos encontrados, mano." not in driver.page_source #close the program and the browser window. BEWARE driver.close()
def run(): email = read_decrypt(efile) password = read_decrypt(pfile) cemail = str(email) cpassword = str(password) with open("browserdetails.txt", "r") as f: data = [line.rstrip('\n') for line in f] browser = data[0].lower() gpu = data[1].lower() if browser == 'edge': try: requests.get("http://www.google.com") print('Connection Established.') l1 = tk.Label(top, text=" Connection Established. ", bg='white') l1.config(font=('helvetica', 15, "bold")) canvas.create_window(200, 410, window=l1) options = EdgeOptions() options.use_chromium = True options.add_argument("--start-maximized") if gpu == 'no': options.add_argument("window-size=1920,1080") options.add_argument("--headless") options.add_argument("disable-gpu") options.add_argument("-inprivate") driver = Edge(resource_path('msedgedriver.exe'), options=options) driver.get('https://gokano.com/') try: email = WebDriverWait(driver, 3).until( EC.presence_of_element_located((By.NAME, 'email'))) print("Page is ready!") l1 = tk.Label(top, text=" Page is Ready. ", bg='white') l1.config(font=('helvetica', 15, "bold")) canvas.create_window(200, 410, window=l1) email.send_keys(cemail) password = driver.find_element_by_name('password') password.send_keys(cpassword) time.sleep(3) button = driver.find_element_by_class_name('submit') button.click() try: driver.find_element_by_class_name('gokan-alert-error') print("Invalid Credintials") l1 = tk.Label(top, text=" Invalid Credintials. ", bg='white') l1.config(font=('helvetica', 15, "bold")) canvas.create_window(200, 410, window=l1) time.sleep(3) driver.quit() except NoSuchElementException: print('Login sucessful') l1 = tk.Label(top, text=" Login Successful. ", bg='white') l1.config(font=('helvetica', 15, "bold")) canvas.create_window(200, 410, window=l1) except TimeoutException: print("Login Error!") l1 = tk.Label(top, text=" Login Error! ", bg='white') l1.config(font=('helvetica', 15, "bold")) canvas.create_window(200, 410, window=l1) # [email protected] time.sleep(3) driver.quit() time.sleep(3) try: cdp = driver.find_element_by_link_text('Collect daily points') cdp.click() write_time() time.sleep(3) driver.quit() except NoSuchElementException: print('Already collected') l1 = tk.Label(top, text=" Points Already Collected. ", bg='white') l1.config(font=('helvetica', 15, "bold")) canvas.create_window(200, 410, window=l1) time.sleep(3) driver.quit() print('Automation completed') l1 = tk.Label(top, text=" Automation Completed. ", bg='white') l1.config(font=('helvetica', 15, "bold")) canvas.create_window(200, 410, window=l1) time.sleep(3) write_time() driver.quit() except requests.ConnectionError: print('Could not connect') l1 = tk.Label(top, text=" Couldn't Connect. ", bg='white') l1.config(font=('helvetica', 15, "bold")) canvas.create_window(200, 410, window=l1) driver.quit()
passed=passed+1 try: # Open browser. if firstTime == True: browser.get("https://kahoot.it/") else: browser.execute_script("window.open('');") browser.switch_to.window(browser.window_handles[total]) browser.get("https://kahoot.it/") #if firstTime == False: # wait=WebDriverWait(browser, 3) # alert=wait.until(EC.alert_is_present()) # alert.accept() time.sleep((pingms/2)) # Find game id element and enter game code. search=browser.find_element_by_name("gameId") search.click() search.send_keys(qp) search.send_keys(Keys.RETURN) print("-Joined Game") print("-Entering name option") # Wait for browser to catch up. Edit equation later. time.sleep(pingms) # Find nickname element and enter random characters. search=browser.find_element_by_name("nickname") search.click() search.send_keys(Keys.CONTROL+"A") search.send_keys(''.join(random.choice(string.ascii_letters) for _ in range(10))) search.send_keys(Keys.RETURN) except (Exception,NoSuchElementException) as e: # Edit stats to show failed connect.