def send_msg(self, contents, chrome): type_field = chrome.find_element_by_xpath( '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]') type_field.send_keys(contents["text"]) send_button = chrome.find_element_by_xpath( '//*[@id="main"]/footer/div[1]/div[3]/button') send_button.click()
def send_msg_line_by(self, contents, chrome): type_field = chrome.find_element_by_xpath( '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]') for line in contents["text"]: actions = ActionChains(chrome) type_field.send_keys(line) actions.key_down(Keys.SHIFT).send_keys(Keys.ENTER).key_up( Keys.SHIFT).perform() actions.reset_actions() send_button = chrome.find_element_by_xpath( '//*[@id="main"]/footer/div[1]/div[3]/button') send_button.click()
def send_img(self, contents, chrome): attach = chrome.find_element_by_xpath( '//*[@id="main"]/header/div[3]/div/div[2]/div') attach.click() img_button = chrome.find_element_by_xpath( '//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button/input' ) img_button.send_keys(os.path.abspath(contents["media_location"])) time.sleep(1) send_button = chrome.find_element_by_xpath( '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span/div' ) send_button.click()
def __init__(self, name, chrome): print("Creating group object") group_header = chrome.find_element_by_xpath('//*[@id="main"]/header') group_header.click() close_button = chrome.find_element_by_xpath( '//*[@id="app"]/div/div/div[2]/div[3]/span/div/span/div/header/div/div[1]/button' ) time.sleep(0.5) self.name = name self.birth = self.find_birth(chrome) self.desc = self.find_desc(chrome) self.size = self.find_size(chrome) self.prev_msg_hash = 0 close_button.click() # Create a parser object self.parser = parser()
def at_all(self, chrome): type_field = chrome.find_element_by_xpath( '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]') actions = ActionChains(chrome) for i in range(self.size - 1): actions.send_keys("@") actions.send_keys(Keys.ARROW_DOWN * i) actions.send_keys(Keys.TAB) actions.perform() type_field.send_keys(Keys.ENTER)