【发布时间】:2013-07-17 18:05:37
【问题描述】:
我对 Python 和 Selenium 非常陌生。
我正在尝试创建一个自动脚本,其中加载了一个页面并完成了用户名和密码字段。
当我在 Selenium 中运行自动化时,它工作正常(这是一个简单的过程),但是当我通过 python 服务器运行它时,它不起作用。页面加载,但未填充任何字段。
任何帮助表示赞赏!
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
class Pageload(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://gymbox.com/"
self.verificationErrors = []
self.accept_next_alert = True
def test_pageload(self):
driver = self.driver
driver.get(self.base_url + "/Login")
driver.find_element_by_id("login_Email").clear()
driver.find_element_by_id("login_Email").send_keys("hello")
【问题讨论】:
-
如果您使用 fex Chromes 开发者工具检查源代码,您会发现您正在寻找的元素位于嵌入式 iframe 中。这类似于stackoverflow.com/questions/15047743/…。