PhantomJS没有点击按钮

时间:2017-07-25 16:19:55

标签: python selenium automation phantomjs

我一直试图解决这个问题整整一周,这是我最后一次拍摄(询问stackoverflow)。

我使用含有硒的phantomjs进入YouTube的登录页面并填写凭据并登录。

我进入登录页面,它设法填写电子邮件,但无论我尝试什么,它都不会点击" next"按钮。

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.action_chains import ActionChains
import time
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait

dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap["-phantomjs.page.settings.userAgent-"] = (
    "-Mozilla-5.0 (Windows NT 6.3; WOW64) AppleWebKit-537.36 (KHTML, like Gecko) Chrome-34.0.1847.137 Safari-537.36-"
    )

driver = webdriver.PhantomJS(desired_capabilities=dcap)

driver.set_window_size(1920,1080)
driver.get("https://youtube.com")
driver.find_element_by_class_name("yt-uix-button-content").click()
print("Logging in...")
driver.find_element_by_id("identifierId").send_keys("email")
time.sleep(1)
driver.find_element_by_class_name("ZFr60d").click()

driver.save_screenshot('testing4.png')

现在我已经尝试了所有这些但没有任何运气。

driver.find_element_by_xpath("""//*[@id="identifierNext"]/content/span""").click()

driver.find_element_by_css_selector("#identifierNext>content>span").click()

webdriver.ActionChains(driver).move_to_element(element).click(element).perform()

driver.find_element_by_id("identifierNext").click()

我还想补充一点,点击元素可以很好地处理没有PhantomJS的硒。

点击下一步时,会有一个大约1秒的滑动动画。

如果有人在这里帮助我,我将非常感激。

0 个答案:

没有答案
相关问题