<small id='jjMio'></small><noframes id='jjMio'>

      <bdo id='jjMio'></bdo><ul id='jjMio'></ul>
  1. <i id='jjMio'><tr id='jjMio'><dt id='jjMio'><q id='jjMio'><span id='jjMio'><b id='jjMio'><form id='jjMio'><ins id='jjMio'></ins><ul id='jjMio'></ul><sub id='jjMio'></sub></form><legend id='jjMio'></legend><bdo id='jjMio'><pre id='jjMio'><center id='jjMio'></center></pre></bdo></b><th id='jjMio'></th></span></q></dt></tr></i><div id='jjMio'><tfoot id='jjMio'></tfoot><dl id='jjMio'><fieldset id='jjMio'></fieldset></dl></div>

    <legend id='jjMio'><style id='jjMio'><dir id='jjMio'><q id='jjMio'></q></dir></style></legend>
  2. <tfoot id='jjMio'></tfoot>

    1. Selenium 2.53.5 httplib.BadStatusLine: '' Python

      时间:2023-07-05
    2. <tfoot id='xaXJP'></tfoot>
        <tbody id='xaXJP'></tbody>

      <legend id='xaXJP'><style id='xaXJP'><dir id='xaXJP'><q id='xaXJP'></q></dir></style></legend>

        <small id='xaXJP'></small><noframes id='xaXJP'>

              <i id='xaXJP'><tr id='xaXJP'><dt id='xaXJP'><q id='xaXJP'><span id='xaXJP'><b id='xaXJP'><form id='xaXJP'><ins id='xaXJP'></ins><ul id='xaXJP'></ul><sub id='xaXJP'></sub></form><legend id='xaXJP'></legend><bdo id='xaXJP'><pre id='xaXJP'><center id='xaXJP'></center></pre></bdo></b><th id='xaXJP'></th></span></q></dt></tr></i><div id='xaXJP'><tfoot id='xaXJP'></tfoot><dl id='xaXJP'><fieldset id='xaXJP'></fieldset></dl></div>
                <bdo id='xaXJP'></bdo><ul id='xaXJP'></ul>
                本文介绍了Selenium 2.53.5 httplib.BadStatusLine: '' Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 Python 2.7 中的 Selenium 2.53.5 以在线形式自动注册序列号.该脚本已经运行了两个多月,但是昨天我开始运行它时开始收到错误:httplib.BadStatusLine: ''.有什么已知的解决方法吗?我读过前导/尾随换行符可能会弄乱 url 的检索,但我似乎无法确定问题所在.

                Im trying to automate the registration of serial numbers in an online form using Selenium 2.53.5 in Python 2.7. The script has been working for 2+ months, but yesterday I started receiving an error right when I go to run it: httplib.BadStatusLine: ''. Is there any known fix for this? I've read that leading/trailing new line characters can mess up the retrieving of the url but I can't seem to identify the issue.

                代码:

                import sys
                import time
                
                from selenium import webdriver
                from selenium.webdriver.chrome.options import Options
                
                class SerialSet:
                    def __init__(self, fileName, driverPath, user, password):
                        self.fn = fileName
                        self.failedSerials = []
                        self.driver = webdriver.Chrome(driverPath)
                        self.aloSuccess = False
                        self.user = user
                        self.password = password
                
                    def parseSerialFile(self):
                        with open(self.fn, 'r') as f:
                            self.serials = [line.strip() for line in f]
                
                    def setCountrySN(self, serial, driver):
                        driver.find_element_by_xpath("//select/option[@value='USA']").click()
                        driver.find_element_by_id("serialno").send_keys(serial)
                        driver.find_element_by_xpath("//input[@value='Continue'][@type='button']").click()
                
                    def submitState(self, driver):
                        driver.find_element_by_xpath("//select/option[@value='CT']").click()
                        driver.find_element_by_id("Continue1").click()
                
                    def login(self, driver):
                        driver.find_element_by_xpath("//*[@id='accountname']").send_keys(self.user)
                        driver.find_element_by_xpath("//*[@id='accountpassword']").send_keys(self.password)
                        driver.find_element_by_xpath("//*[@id='signInHyperLink']").click()
                
                    def initiateSN(self, serial, driver):
                        # select country and enter serialno
                        driver.get("http://supportform.apple.com/201110/")
                        self.setCountrySN(serial, driver)
                
                        # enter login
                        time.sleep(3)
                        if driver.current_url == "http://supportform.apple.com/201110/":
                            return False
                        self.login(driver)
                
                        # select state and continue
                        time.sleep(3)
                        self.submitState(driver)
                
                        # final submit
                        time.sleep(3)
                        driver.find_element_by_id("finalContinue").click()
                        return True
                
                    def newSN(self, serial, driver):
                        # select country and enter serialno
                        driver.get("http://supportform.apple.com/201110/")
                        self.setCountrySN(serial, driver)
                
                        # select state and continue
                        time.sleep(3)
                        if driver.current_url == "http://supportform.apple.com/201110/":
                            return False
                        self.submitState(driver)
                
                        # final submit
                        time.sleep(3)
                        driver.find_element_by_id("finalContinue").click()
                        return True
                
                    def automateSerials(self):
                        for i in self.serials:
                            if self.aloSuccess == False:
                                if not self.initiateSN(i, self.driver):
                                    self.failedSerials.append(i)
                                    del i
                                else:
                                    self.aloSuccess = True
                            else:
                                if not self.newSN(i, self.driver):
                                    self.failedSerials.append(i)
                                    del i
                        self.driver.quit()
                        print(str(len(self.serials) - len(self.failedSerials)) + ":" + str(len(self.serials)))
                def main():
                    newSet = SerialSet(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
                    newSet.parseSerialFile()
                    newSet.automateSerials()
                
                if __name__ == "__main__":
                    main()
                

                错误:

                Traceback (most recent call last):
                  File "automate.py", line 90, in <module>
                    main()
                  File "automate.py", line 85, in main
                    newSet = SerialSet(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
                  File "automate.py", line 11, in __init__
                    self.driver = webdriver.Chrome(driverPath)
                  File "/Library/Python/2.7/site-    packages/selenium/webdriver/chrome/webdriver.py", line 67, in __init__
                    desired_capabilities=desired_capabilities)
                  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
                self.start_session(desired_capabilities, browser_profile)
                  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
                response = self.execute(Command.NEW_SESSION, capabilities)
                  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute
                response = self.command_executor.execute(driver_command, params)
                  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 401, in execute
                return self._request(command_info[0], url, body=data)
                  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 432, in _request
                    resp = self._conn.getresponse()
                  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1132, in getresponse
                response.begin()
                  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 453, in begin
                version, status, reason = self._read_status()
                  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 417, in _read_status
                raise BadStatusLine(line)
                httplib.BadStatusLine: ''
                

                推荐答案

                确保您使用的是最新版本的chromedriver:http://chromedriver.storage.googleapis.com/2.25/chromedriver_linux64.zip

                Make sure your using the latest version chromedriver: http://chromedriver.storage.googleapis.com/2.25/chromedriver_linux64.zip

                我安装了 chromedriver 2.0 出现了这个错误,

                I installed chromedriver 2.0 and got this error,

                当我升级到 2.25 时,它消除了这个错误.

                when I upgraded to 2.25 it got rid of this error.

                这篇关于Selenium 2.53.5 httplib.BadStatusLine: '' Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何使用 python selenium 获取浏览器网络日志 下一篇:谷歌浏览器在使用 selenium 启动后立即关闭

                相关文章

                    <bdo id='k5QBJ'></bdo><ul id='k5QBJ'></ul>
                  <tfoot id='k5QBJ'></tfoot>
                1. <legend id='k5QBJ'><style id='k5QBJ'><dir id='k5QBJ'><q id='k5QBJ'></q></dir></style></legend>

                  <small id='k5QBJ'></small><noframes id='k5QBJ'>

                2. <i id='k5QBJ'><tr id='k5QBJ'><dt id='k5QBJ'><q id='k5QBJ'><span id='k5QBJ'><b id='k5QBJ'><form id='k5QBJ'><ins id='k5QBJ'></ins><ul id='k5QBJ'></ul><sub id='k5QBJ'></sub></form><legend id='k5QBJ'></legend><bdo id='k5QBJ'><pre id='k5QBJ'><center id='k5QBJ'></center></pre></bdo></b><th id='k5QBJ'></th></span></q></dt></tr></i><div id='k5QBJ'><tfoot id='k5QBJ'></tfoot><dl id='k5QBJ'><fieldset id='k5QBJ'></fieldset></dl></div>