python
wind7下安装python2.7+selenium+火狐 有版本要求吗?为什么我以前用weind10装的python2.7 运行的程序 在wind7上到处报错我的都是win7 的 安时候也没看到有要求呀 梦想家 发表于 2016-11-26 15:25
我的都是win7 的 安时候也没看到有要求呀
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
classtest (unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.implicitly_wait(30)
self.base_url = "http://test.robotscloud.com/"
self.verificationErrors = []
self.accept_next_alert = True
def test_(self):
driver = self.driver
driver.get(self.base_url + "/adminlogin")
driver.find_element_by_id("email").clear()
driver.find_element_by_id("email").send_keys("2@163.com")
driver.find_element_by_id("password").clear()
driver.find_element_by_id("password").send_keys("www123456")
driver.find_element_by_id("submit").click()
driver.find_element_by_id("email").click()
driver.find_element_by_id("old_password").clear()
driver.find_element_by_id("old_password").send_keys("123")
driver.find_element_by_css_selector("div.form-group > button.btn.btn-blue").click()
driver.find_element_by_id("old_password").clear()
driver.find_element_by_id("old_password").send_keys("1234567890111111")
driver.find_element_by_id("new_password").clear()
driver.find_element_by_id("new_password").send_keys("1234")
driver.find_element_by_id("new_password").clear()
driver.find_element_by_id("new_password").send_keys("123456")
driver.find_element_by_id("repeat").clear()
driver.find_element_by_id("repeat").send_keys("1234")
driver.find_element_by_css_selector("div.form-group > button.btn.btn-blue").click()
driver.find_element_by_id("repeat").clear()
driver.find_element_by_id("repeat").send_keys("123456")
driver.find_element_by_css_selector("div.form-group > button.btn.btn-blue").click()
driver.find_element_by_id("old_password").click()
# driver.find_element_by_id("old_password").clear()
driver.find_element_by_id("old_password").send_keys("123456")
driver.find_element_by_id("new_password").click()
driver.find_element_by_id("new_password").clear()
driver.find_element_by_id("new_password").send_keys("!@123456")
driver.find_element_by_id("repeat").clear()
driver.find_element_by_id("repeat").send_keys("!@123456")
driver.find_element_by_css_selector("div.form-group > button.btn.btn-blue").click()
driver.find_element_by_id("new_password").clear()
driver.find_element_by_id("new_password").send_keys("123456")
driver.find_element_by_id("repeat").clear()
driver.find_element_by_id("repeat").send_keys("123456")
driver.find_element_by_css_selector("div.form-group > button.btn.btn-blue").click()
# driver.find_element_by_id("old_password").click()
driver.find_element_by_id("old_password").clear()
driver.find_element_by_id("old_password").send_keys("!@123456")
driver.find_element_by_css_selector("div.form-group > button.btn.btn-blue").click()
driver.find_element_by_css_selector("#resetPassModal > div.modal-dialog > div.modal-content > div.modal-header > button.close").click()
driver.find_element_by_link_text(u"安全退出").click()
driver.find_element_by_css_selector("button.btn.btn-blue").click()
driver.find_element_by_id("email").clear()
driver.find_element_by_name("email").send_keys("2@163.com")
driver.find_element_by_id("password").clear()
driver.find_element_by_id("password").send_keys("www123456")
driver.find_element_by_link_text(u"登录").click()
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException as e: return False
return True
def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException as e: return False
return True
def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
能帮我运行下这个程序吗,在wind10下面运行正常 在wind7运行连登陆都登录不了 15889369825 发表于 2016-11-26 15:31
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import...
E
======================================================================
ERROR: test_ (__main__.test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/123.py", line 27, in test_
driver.find_element_by_id("old_password").clear()
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 269, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 752, in find_element
'value': value})['value']
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"old_password"}
(Session info: chrome=54.0.2840.87)
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)
----------------------------------------------------------------------
Ran 1 test in 40.736s
FAILED (errors=1) 你win7下的火狐浏览器是什么版本的? 掉渣饼 发表于 2016-11-26 20:40
你win7下的火狐浏览器是什么版本的?
换了几个版本 45.5 49 50 15889369825 发表于 2016-11-28 09:09
换了几个版本 45.5 49 50
试试更低的火狐浏览器版本可以在网上百度下根据你selenium版本选择,在安装火狐浏览器后把自动更新勾掉 掉渣饼 发表于 2016-11-29 09:15
试试更低的火狐浏览器版本可以在网上百度下根据你selenium版本选择,在安装火狐浏览器后把自动更新勾掉
可以发下你的python版本selenmiun版本和火狐版本么,越具体越好, :)
页:
[1]