selenium自学之路:处理HTML5的视频播放,截图

from selenium import webdriver
from time import sleep

driver=webdriver.Chrome()
driver.get('http://videojs.com/')
video=driver.find_element_by_xpath('//*[@id="preview-player_html5_api"]')
url=driver.execute_script('return arguments[0].currentSrc;',video)
print(url)

print('start')
driver.execute_script('return arguments[0].play()',video)

sleep(15)

print('stop')
driver.execute_script('arguments[0].pause()',video)
driver.quit()


from selenium import webdriver
from time import sleep

driver=webdriver.Chrome()
driver.get('http://www.baidu.com/')
driver.find_element_by_id('kw').send_keys('selenium')
driver.find_element_by_id('su').click()
#截图
driver.get_screenshot_as_file('d:/baidu.png')
driver.quit()


你可能感兴趣的:(selenium)