from pic_diff_recognizer.searchHandler import SearchHandler from violent_webdriver import Chrome from selenium.webdriver.chrome.options import Options # add some useful options :) chrome_options = Options() chrome_options.add_argument("--headless") chrome_options.add_argument("disable-infobars") chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']) # init driver , executable_path should be your own path! dr = Chrome.violent_chromedriver(chrome_options=chrome_options, executable_path='/usr/local/bin/chromedriver') # init searchHandler search_handler = SearchHandler(browser=dr) # search and saving baseline images in current directory named baseline search_handler.traverse_href(origin_url='https://gitbook.cn/gitchat/author/5cea0bfbb78cc870612d8bba') # -------------------- assuming after some iterations of current project ----------------------------- search_handler.url_histories = [] # load baseline images search_handler.picture_handler.load_base_line() # search and comparing screen shots and baseline images search_handler.traverse_href(origin_url='https://gitbook.cn/gitchat/author/5cea0bfbb78cc870612d8bba', compare_baseline_and_screen_shots=True)
from violent_webdriver import Chrome # the value of executable_path should be your own path dr = Chrome.violent_chromedriver(executable_path='C://MyDownloads/Download/chrome-win32/chromedriver.exe') dr.get('https://www.baidu.com') dr.implicitly_wait(30) trigger = dr.find_element_by_name('tj_trtieba') dr.v_send_keys(locate_rule={'tag name': 'input', 'class': 's_ipt'}, message='test') dr.v_click(locate_rule={'tag name': 'input', 'value': '百度一下'}) print(dr.is_page_refreshed(trigger))
if __name__ == '__main__': import datetime import difflib from violent_webdriver import Chrome from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.action_chains import ActionChains import os chrome_options = Options() # chrome_options.add_argument("--headless") # chrome_options.add_argument("disable-infobars") chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']) dr = Chrome.violent_chromedriver(chrome_options=chrome_options, executable_path='../../chromedriver.exe') dr.set_window_size(1920, 1080) origin_url = 'https://www.famaomao.com/' dr.get(origin_url) dr.implicitly_wait(10) t = './&which=&client_id=100410602&redirect_uri=http%3A%2F%2Fwww.jianshu.com%2Fusers%2Fauth%2Fqq_connect%2Fcallback&response_type=code&state=%257B%257D_1586954364204138' dr.save_screenshot(f'{t}.png') dr.quit() # find_script = "function imgsStatus(){ \ # let emptyList = new Array(); \ # let imgs = document.getElementsByTagName('img'); \ # for (i=0; i<imgs.length; i++){ \ # if (imgs[i].complete){ \
from violent_webdriver import Chrome # the value of executable_path should be your own path dr = Chrome.violent_chromedriver( executable_path='C://MyDownloads/Download/chrome-win32/chromedriver.exe', use_mobile_emulation=True) dr.get('https://www.baidu.com')
def before(self): self.driver = Chrome.violent_chromedriver(CHROMEDRIVER_PATH) self.driver.set_window_size(1920, 1080) self.driver.implicitly_wait(10)