def activate_mac_filtration(self, browser: webdriver, action: str): """ """ if action == "deny" or action == "allow" or action == "disable": all_wifi_types = browser.find_elements_by_name("w_band") for wifi_type in all_wifi_types: if wifi_type.get_attribute("value") == '2': wifi_type.click() browser.implicitly_wait(3) deny_types = browser.find_elements_by_name( "mac_mode_radio") for deny_type in deny_types: value = deny_type.get_attribute("value") if value == action: deny_type.click() break self.save(browser) browser.implicitly_wait(3) all_wifi_types = browser.find_elements_by_name("w_band") for wifi_type in all_wifi_types: if wifi_type.get_attribute("value") == '5': wifi_type.click() browser.implicitly_wait(3) deny_types = browser.find_elements_by_name( "mac_mode_radio") for deny_type in deny_types: value = deny_type.get_attribute("value") if value == action: deny_type.click() break self.save(browser) browser.implicitly_wait(3) else: raise TypeError( "The entering params must be allow, deny or disable")
def logIn(driver: webdriver, user_id: str, password: str): driver.get("https://classroom.google.com/u/0/h") while (True): driver.find_element_by_id("identifierId").send_keys(user_id) driver.find_element_by_id("identifierNext").click() time.sleep(3) if len(driver.find_elements_by_name("password")) > 0: break try: temp = driver.find_element_by_id("identifierId").get_attribute( "outerHTML") temp = temp[temp.index("aria-invalid") + 14] if temp == 't': user_id = input("Invalid mail-id. \nPlease enter mail-id:") driver.find_element_by_id("identifierId").clear() else: print( "Kindly try again. One of the following reasons may be possible for the error:\n1. No internet connection\n2. You have 2-factor authentication enabled for your mail account" ) driver.get("https://classroom.google.com/u/0/h") time.sleep(3) if '0/h' in driver.current_url: return True return False except: print( "Kindly try again. One of the following reasons may be possible for the error:\n1. No internet connection\n2. You have 2-factor authentication enabled for your mail account" ) driver.get("https://classroom.google.com/u/0/h") time.sleep(3) if '0/h' in driver.current_url: return True return False while (True): WebDriverWait(driver, timeout=10).until( expected_conditions.visibility_of_element_located( (By.NAME, "password"))).send_keys(password) driver.find_element_by_id("passwordNext").click() time.sleep(3) if '0/h' in driver.current_url: return True try: temp = driver.find_element_by_id("password").get_attribute( "outerHTML") temp = temp[temp.index("aria-invalid") + 14] if temp == 't': password = getpass.getpass( prompt='Invalid password. Please enter your password: '******'0/h' in driver.current_url: return True return False except: if '0/h' in driver.current_url: return True driver.get("https://classroom.google.com/u/0/h") time.sleep(3) if '0/h' in driver.current_url: return True print( "Kindly try again. One of the following reasons may be possible for the error:\n1. No internet connection\n2. You have 2-factor authentication enabled for your mail account" ) return False