def naver_login(browser): browser.find_element_by_xpath("""//*[@id="account"]/a""").click() randomized_sleep() copy_input(browser, '//*[@id="id"]', naver_login['id']) copy_input(browser, '//*[@id="pw"]', naver_login['pw']) browser.find_element_by_xpath("""//*[@id="log.login"]""").click() randomized_sleep(2)
def scroll_up(self, offset=-1, wait=2): if offset == -1: self.driver.execute_script("window.scrollTo(0, 0)") else: self.driver.execute_script("window.scrollTo(0, -%s" % offset) randomized_sleep(wait)
def page_down(self, wait=0.3): self.driver.execute_script("window.scrollTo(0, 1080") randomized_sleep(wait)
def scroll_down(self, wait=0.3): self.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight") randomized_sleep(wait)
def iframe_to_driver(browser, url): browser.get(url) browser.driver.switch_to.frame("cafe_main") randomized_sleep()
def click_and_input(browser, xpath, input): browser.find_element_by_xpath(xpath).click() browser.find_element_by_xpath(xpath).send_keys(input) randomized_sleep()
def copy_input(browser, xpath, input): browser.find_element_by_xpath(xpath).click() pyperclip.copy(input) browser.find_element_by_xpath(xpath).send_keys(Keys.CONTROL, 'v') randomized_sleep()
def scroll_up(self, offset=-1, wait=2): if offset == -1: self.driver.execute_script('window.scrollTo(0, 0') else: self.driver.execute_script(f'window.scrollBy(0, {offset})') randomized_sleep(wait)