15889369825 发表于 2016-10-11 17:59:12

应该是我调试的时候误删了,不好意思了,现在运行脚本打不开我脚本中的链接地址还提示
E
======================================================================
ERROR: test_3 (__main__.test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\admin\Desktop\3.py", line 12, in setUp
    self.driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __init__
    self.binary, timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 99, in _wait_until_connectable
    "The browser appears to have exited "
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.


----------------------------------------------------------------------
Ran 1 test in 21.165s

FAILED (errors=1)
这是什么原因

15889369825 发表于 2016-10-11 18:01:14

为毛在这里回复帖子要审核

15889369825 发表于 2016-10-11 18:06:24

若尘_51 发表于 2016-10-11 17:31
这个脚本你只需要将
class 3 改成 class test 就可以运行

应该是我调试的时候误删了,不好意思了,现在运行脚本打不开我脚本中的链接地址还提示
E
======================================================================
ERROR: test_3 (__main__.test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\admin\Desktop\3.py", line 12, in setUp
    self.driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __init__
    self.binary, timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 99, in _wait_until_connectable
    "The browser appears to have exited "
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.


----------------------------------------------------------------------
Ran 1 test in 21.165s

FAILED (errors=1)
这是什么原因

15889369825 发表于 2016-10-11 18:07:22

若尘_51 发表于 2016-10-11 17:31
这个脚本你只需要将
class 3 改成 class test 就可以运行

应该是我调试的时候误删了,不好意思了,现在运行脚本打不开我脚本中的链接地址还提示
E
======================================================================
ERROR: test_3 (__main__.test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\admin\Desktop\3.py", line 12, in setUp
    self.driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __init__
    self.binary, timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 99, in _wait_until_connectable
    "The browser appears to have exited "
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.


----------------------------------------------------------------------
Ran 1 test in 21.165s

FAILED (errors=1)
这是什么原因

15889369825 发表于 2016-10-11 18:07:49

应该是我调试的时候误删了,不好意思了,现在运行脚本打不开我脚本中的链接地址还提示
E
======================================================================
ERROR: test_3 (__main__.test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\admin\Desktop\3.py", line 12, in setUp
    self.driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __init__
    self.binary, timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 99, in _wait_until_connectable
    "The browser appears to have exited "
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.


----------------------------------------------------------------------
Ran 1 test in 21.165s

FAILED (errors=1)
这是什么原因

若尘_51 发表于 2016-10-12 08:30:58

15889369825 发表于 2016-10-11 17:58
应该是我调试的时候误删了,不好意思了,现在运行脚本打不开我脚本中的链接地址还提示
E
=============== ...

通常出现这个错误是因为你的火狐没有安装在默认安装路径:
C盘的"C:\Program Files (x86)\Mozilla Firefox\firefox.exe这个路径

晨曦丶寒 发表于 2016-10-12 10:37:53

本帖最后由 晨曦丶寒 于 2016-10-12 10:41 编辑

15889369825 发表于 2016-10-11 17:58
应该是我调试的时候误删了,不好意思了,现在运行脚本打不开我脚本中的链接地址还提示
E
=============== ...
def test_3(self):
      driver = self.driver
      driver.get(self.base_url + "/")
      driver.find_element_by_id("email").clear()
      driver.find_element_by_id("email").send_keys("15889369825@163.com")
      driver.find_element_by_id("password").clear()
      driver.find_element_by_id("password").send_keys("123456")
      driver.find_element_by_id("check").clear()
      driver.find_element_by_id("check").send_keys("5223")
这段代码 driver.get(self.base_url + "/"),去掉括号里面的+ "/"
   

15889369825 发表于 2016-10-12 11:07:58

晨曦丶寒 发表于 2016-10-12 10:37
def test_3(self):
      driver = self.driver
      driver.get(self.base_url + "/")


谢谢!已经弄好了,selenium2.53兼容火狐浏览器问题

15889369825 发表于 2016-10-12 15:37:40

若尘_51 发表于 2016-10-12 08:30
通常出现这个错误是因为你的火狐没有安装在默认安装路径:
C盘的"C:\Program Files (x86)\Mozilla Firef ...

重装了狐火,脚本能跑完,但跑完后pyhton shell还是会这样提示,

若尘_51 发表于 2016-10-12 15:49:19

15889369825 发表于 2016-10-12 15:37
重装了狐火,脚本能跑完,但跑完后pyhton shell还是会这样提示,

你的火狐和selenium的版本是多少?
另外火狐安装的路径?
错误提示,以及脚本都附上吧。我在我的机器上跑跑~~

15889369825 发表于 2016-10-12 16:18:42

若尘_51 发表于 2016-10-12 15:49
你的火狐和selenium的版本是多少?
另外火狐安装的路径?
错误提示,以及脚本都附上吧。我在我的机器上 ...

pip (8.1.2)
selenium (2.53.6)
setuptools (0.6rc11)
火狐:45.4.0路径:C:\Program Files\Mozilla Firefox
脚本:# -*- 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

class test(unittest.TestCase):
    def setUp(self):
      self.driver = webdriver.Firefox()
      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 + "/")
      driver.find_element_by_id("email").clear()
      driver.find_element_by_id("email").send_keys("15889369825@163.com")
      driver.find_element_by_id("password").clear()
      driver.find_element_by_id("password").send_keys("qwe123")
      driver.find_element_by_id("check").clear()
      driver.find_element_by_id("check").send_keys("7909")
      driver.find_element_by_id("submit").click()
      driver.find_element_by_id("userEmail").click()
      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("12")
      driver.find_element_by_id("new_password").clear()
      driver.find_element_by_id("new_password").send_keys("12")
      driver.find_element_by_id("repeat").clear()
      driver.find_element_by_id("repeat").send_keys("12")
      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("!@#123456")
      driver.find_element_by_id("new_password").clear()
      driver.find_element_by_id("new_password").send_keys("123456")
      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("qq123456")
      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("userEmail").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").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_id("new_password").clear()
      driver.find_element_by_id("new_password").send_keys("qwe")
      driver.find_element_by_id("repeat").clear()
      driver.find_element_by_id("repeat").send_keys("qwe")
      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("qwe123")
      driver.find_element_by_id("repeat").clear()
      driver.find_element_by_id("repeat").send_keys("qwe123")
      driver.find_element_by_css_selector("div.form-group > button.btn.btn-blue").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()


错误提示:E
======================================================================
ERROR: test_ (__main__.test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\admin\Desktop\xiugai.py", line 53, in test_
    driver.find_element_by_id("userEmail").click()
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 72, in click
    self._execute(Command.CLICK_ELEMENT)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 461, in _execute
    return self._parent.execute(command, params)
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)
WebDriverException: Message: Element is not clickable at point (1103.9833374023438, 24.5). Other element would receive the click: <div style="display: block;" class="modal fade modal-resetPass in" id="resetPassModal" tabindex="-1" role="dialog" aria-labelledby="resetPassModalLabel" aria-hidden="true"></div>


----------------------------------------------------------------------
Ran 1 test in 27.051s

FAILED (errors=1)
>>>

若尘_51 发表于 2016-10-12 16:32:14

注:
(1)你的脚本可读性太差了,建议学习下别人的脚本。
(2)学习阅读脚本报错的信息:
Traceback (most recent call last):
File "C:\Users\admin\Desktop\xiugai.py", line 53, in test_
    driver.find_element_by_id("userEmail").click()
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 72, in click
    self._execute(Command.CLICK_ELEMENT)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 461, in _execute
    return self._parent.execute(command, params)
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)
WebDriverException: Message: Element is not clickable at point (1103.9833374023438, 24.5). Other element would receive the click: <div style="display: block;" class="modal fade modal-resetPass in" id="resetPassModal" tabindex="-1" role="dialog" aria-labelledby="resetPassModalLabel" aria-hidden="true"></div>


脚本:# -*- 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

class test(unittest.TestCase):
    def setUp(self):
      self.driver = webdriver.Firefox()
      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 + "/")
      driver.find_element_by_id("email").clear()
      driver.find_element_by_id("email").send_keys("15889369825@163.com")
      driver.find_element_by_id("password").clear()
      driver.find_element_by_id("password").send_keys("qwe123")
      driver.find_element_by_id("check").clear()
      driver.find_element_by_id("check").send_keys("7909")
      driver.find_element_by_id("submit").click()
      driver.find_element_by_id("userEmail").click()
      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("12")
      driver.find_element_by_id("new_password").clear()
      driver.find_element_by_id("new_password").send_keys("12")
      driver.find_element_by_id("repeat").clear()
      driver.find_element_by_id("repeat").send_keys("12")
      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("!@#123456")
      driver.find_element_by_id("new_password").clear()
      driver.find_element_by_id("new_password").send_keys("123456")
      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("qq123456")
      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("userEmail").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").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_id("new_password").clear()
      driver.find_element_by_id("new_password").send_keys("qwe")
      driver.find_element_by_id("repeat").clear()
      driver.find_element_by_id("repeat").send_keys("qwe")
      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("qwe123")
      driver.find_element_by_id("repeat").clear()
      driver.find_element_by_id("repeat").send_keys("qwe123")
      driver.find_element_by_css_selector("div.form-group > button.btn.btn-blue").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()

15889369825 发表于 2016-10-12 16:38:46

嗯!谢谢,刚开始学习这个,还有很多不懂,能推荐些资料看么
页: 1 [2]
查看完整版本: 有selenium IDE录制的脚本导入到