Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium clickAt命令是否适用于无头浏览器?_Selenium_Selenium Webdriver_Web Scraping_Phantomjs_Webautomation - Fatal编程技术网

Selenium clickAt命令是否适用于无头浏览器?

Selenium clickAt命令是否适用于无头浏览器?,selenium,selenium-webdriver,web-scraping,phantomjs,webautomation,Selenium,Selenium Webdriver,Web Scraping,Phantomjs,Webautomation,我正在考虑用无头浏览器取代Firefox,比如PhantomJS(或htmlunit),用于selenium的网页抓取活动 我认为selenium中的clickAt命令依赖于页面图形呈现,在PhantomJS中它不起作用。有人能证实这一点吗?这对我很有效(在Python 3.5中): 从selenium导入webdriver 导入时间 如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu': driver=webdriver.PhantomJS(“”) 驱动程序。设

我正在考虑用无头浏览器取代Firefox,比如
PhantomJS
(或
htmlunit
),用于
selenium
的网页抓取活动

我认为selenium中的
clickAt
命令依赖于页面图形呈现,在
PhantomJS
中它不起作用。有人能证实这一点吗?

这对我很有效(在Python 3.5中):

从selenium导入webdriver
导入时间
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
driver=webdriver.PhantomJS(“”)
驱动程序。设置窗口大小(1400,1000)
驱动程序。获取(“http://www.google.com")
el=驱动程序。通过名称(“btnI”)查找元素
action=webdriver.common.action\u chains.ActionChains(驱动程序)
动作。使用偏移量(el,5,5)将元素移动到元素
操作。单击()
action.perform()
时间。睡眠(2)
driver.save_屏幕截图('screen.png')
这对我很有用(在Python 3.5中):

从selenium导入webdriver
导入时间
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
driver=webdriver.PhantomJS(“”)
驱动程序。设置窗口大小(1400,1000)
驱动程序。获取(“http://www.google.com")
el=驱动程序。通过名称(“btnI”)查找元素
action=webdriver.common.action\u chains.ActionChains(驱动程序)
动作。使用偏移量(el,5,5)将元素移动到元素
操作。单击()
action.perform()
时间。睡眠(2)
driver.save_屏幕截图('screen.png')
from selenium import webdriver
import time

if __name__ == '__main__':       
    driver = webdriver.PhantomJS('<YourPathtoPhantom>')    
    driver.set_window_size(1400, 1000)
    driver.get("http://www.google.com")
    el = driver.find_element_by_name('btnI')

    action = webdriver.common.action_chains.ActionChains(driver)
    action.move_to_element_with_offset(el, 5, 5)
    action.click()
    action.perform()
    time.sleep(2)
    driver.save_screenshot('screen.png')