Google chrome浏览器打不开网页,显示ERR_Failed...等问题的解决方法

新装好的win7系统,打开Google浏览器,显示网页可能暂时无法连接,或者它已永久性的移动到了新地址。在网络搜索很多资料,发现解决方法如下,亲测成功。

原因,该服务依赖的TCP/IP 协议有问题。

解决办法:

  1、开始——运行——regedit.exe,打开注册表编辑器,删除以下两个键:HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Winsock(右键删除) HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Winsock2(右键删除)

  2、找到 C:\Windows\inf\nettcpip.inf文件,该文件为 tcp/ip协议文件

  3、控制面板->网络和Internet->网络和共享中心->更改适配器设置->右键本地连接->属性

  4、先选择TCP/IPv6->安装->协议->添加->从磁盘安装->然后在路径里浏览找到第2步中的文件路径找到nettcpip.inf,确定然后选择“TCP/IPv6”。

  对于ipv4协议重复同样的操作,最后选择TCP/IPv4,即: TCP/IPv4->安装->协议->添加->从磁盘安装->然后在路径里浏览找到第2步中的文件路径,nettcpip.inf 然后选择“TCP/IPv4”。


 

对于chrome浏览器,除了上面的问题,还有以下相关问题,一一给出了解决方法,我没有遇到过以下的问题,遇到过的朋友可以测试解决方法:

(1) 无法访问此网站,连接已重置------错误代码:ERR_CONNECTION_RESET

     这个错误可能是因为国内不能访问国外受限的网站导致的问题,可以参考下面经验"解决Chrome浏览器不能登录和更新问题"的步骤解决这个问题。

  1. 注:此问题也有可能是使用http协议来访问需要使用https协议访问的站点,可以尝试将地址改成https://xxx的形式来访问,或是在Chrome地址栏中输入chrome://net-internals/#hsts ,将网站的域名加入到"HTTP严格传输安全"列表,这样以后访问该网站时,Chrome就会强制使用https来打开该网站。

    解决Chrome无法访问此网站或无法显示此网页问题
    解决Chrome无法访问此网站或无法显示此网页问题
    解决Chrome无法访问此网站或无法显示此网页问题
    (2)无法访问此网站,无法找到服务器DNS address------错误代码:DNS_PROBE_FINISHED_NXDOMAIN 
    参考下面经验"Chrome如何清除DNS缓存?"的步骤,清除Chrome DNS缓存后再看问题是否解决。解决Chrome无法访问此网站或无法显示此网页问题 
    (3)网页可能暂时无法连接,或者它已永久性地移动到了新网址------ 错误代码:ERR_FAILED
    1. 按下Win+R,打开运行对话框,输入"cmd",回车打开命令行程序,确认命令行程序运行在管理员模式(标题中有"管理员"字样)。在命令行程序中输入netsh winsock reset,然后重启电脑。

      解决Chrome无法访问此网站或无法显示此网页问题
      解决Chrome无法访问此网站或无法显示此网页问题
      解决Chrome无法访问此网站或无法显示此网页问题 
      (4)网页可能暂时无法连接,或者它已永久性地移动到了新网址------ 错误代码:ERR_CONNECTION_ABORTED
      参考下面经验"解决Chrome浏览器不能访问https网站的问题"中的描述,增加Chrome启动参数 –ssl-version-min=tls1,重启Chrome解决Chrome无法访问此网站或无法显示此网页问题 
      (5)无法显示此网页,错误代码:"ERR_NAME_NOT_RESOLVED"或"ERR_CONNECTION_REFUSED"
      1. 确认地址栏中的网址是否正确?
      2. 在其它浏览器(如:IE)中打开问题网页,如果也有这个问题,则说明是网络的问题。
      3. 如果其它浏览器中没有这个问题,则参考下面经验"Chrome如何清除DNS缓存?"的步骤,清除Chrome DNS缓存后再看问题是否解决。
      4. 确认代理是否正确或没有问题?
      5.在Chrome地址栏中输入chrome://net-internals/#proxy,确认是否设置正确?
      解决Chrome无法访问此网站或无法显示此网页问题
      解决Chrome无法访问此网站或无法显示此网页问题
      解决Chrome无法访问此网站或无法显示此网页问题 
      (6)无法显示此网页,错误代码:"ERR_NAME_RESOLUTION_FAILED"
      这个错误是由于DNS配置有问题,通过更改DNS配置来解决此问题。
      1. 打开网络和共享中心。  
      2. 选择访问Internet的网络适配器,鼠标右键菜单,点击"属性"。  
      3. 在网络适配器属性对话框中,选择IPv4协议,点击"属性"。
      4. 选择"使用自定义的DNS服务器",首选DNS服务器输入8.8.8.8,备选DNS服务器输入8.8.4.4,点"确定"。
      注:8.8.8.8和8.8.4.4是Google提供的免费DNS服务器IP地址。
      解决Chrome无法访问此网站或无法显示此网页问题
      解决Chrome无法访问此网站或无法显示此网页问题
      解决Chrome无法访问此网站或无法显示此网页问题
       
      (7)如果出现下图的情况,web服务器拒绝连接

       

      解决方法:

         (1)浏览器--设置--高级--打开代理设置;

       (2)连接--局域网设置

      (3)把自动检测设置前面的勾去掉


       

      以上就是几种常见浏览器问题的解决方法,欢迎补充! 

       

       

转载于:https://www.cnblogs.com/feifei-cyj/p/7503744.html

C:\Users\邓奎林\AppData\Local\Programs\Python\Python311\python.exe C:/Users/邓奎林/PycharmProjects/pythonProject2/dkl/templates/test_notepad_ui.py Traceback (most recent call last): File "C:\Users\邓奎林\AppData\Roaming\Python\Python311\site-packages\selenium\webdriver\common\driver_finder.py", line 64, in _binary_paths raise ValueError(f"The path is not a valid file: {path}") ValueError: The path is not a valid file: C:\Users\邓奎林\PycharmProjects\pythonProject2\chromedriver.exe The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\邓奎林\PycharmProjects\pythonProject2\dkl\templates\test_notepad_ui.py", line 65, in <module> tester.setup_method() File "C:\Users\邓奎林\PycharmProjects\pythonProject2\dkl\templates\test_notepad_ui.py", line 19, in setup_method self.driver = webdriver.Chrome(service=service, options=chrome_options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\邓奎林\AppData\Roaming\Python\Python311\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__ super().__init__( File "C:\Users\邓奎林\AppData\Roaming\Python\Python311\site-packages\selenium\webdriver\chromium\webdriver.py", line 50, in __init__ if finder.get_browser_path(): ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\邓奎林\AppData\Roaming\Python\Python311\site-packages\selenium\webdriver\common\driver_finder.py", line 47, in get_browser_path return self._binary_paths()["browser_path"] ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\邓奎林\AppData\Roaming\Python\Python311\site-packages\selenium\webdriver\common\driver_finder.py", line 78, in _binary_paths raise NoSuchDriverException(msg) from err selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\邓奎林\PycharmProjects\pythonProject2\dkl\templates\test_notepad_ui.py", line 71, in <module> tester.teardown_method() File "C:\Users\邓奎林\PycharmProjects\pythonProject2\dkl\templates\test_notepad_ui.py", line 24, in teardown_method self.driver.quit() ^^^^^^^^^^^ AttributeError: 'TestNotepadUI' object has no attribute 'driver' Process finished with exit code 1
最新发布
05-24
看起来问题出在两个方面: 1. **ChromeDriver路径无效**:`C:\Users\邓奎林\PycharmProjects\pythonProject2\chromedriver.exe` 路径无效,可能是文件不存在或路径拼写错误。 2. **未成功初始化`driver`属性**:由于`webdriver.Chrome()`调用失败,`self.driver`没有被正确初始化,因此在调用`teardown_method`时引发了`AttributeError`。 ### 解决方法 #### 1. 确认ChromeDriver路径有效 确保`chromedriver.exe`文件确实位于您指定的路径下。您可以采取以下步骤来确认: - **手动检查文件**:导航到`C:\Users\邓奎林\PycharmProjects\pythonProject2\`,确认`chromedriver.exe`文件是否存在。 - **使用命令行验证路径**: ```bash dir C:\Users\邓奎林\PycharmProjects\pythonProject2\chromedriver.exe ``` #### 2. 处理`driver`属性未初始化的情况 确保即使初始化失败,也能安全地调用`teardown_method`。可以通过检查`self.driver`是否存在来避免`AttributeError`。 ### 修改后的代码 ```python from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys import time class TestNotepadUI: def setup_method(self): try: # 设置Chrome浏览器路径 chrome_options = Options() chrome_options.binary_location = r"C:\Program Files\Google\Chrome\Application\chrome.exe" # 设置ChromeDriver路径 chromedriver_path = r"C:\Users\邓奎林\PycharmProjects\pythonProject2\chromedriver.exe" service = Service(executable_path=chromedriver_path) # 初始化WebDriver self.driver = webdriver.Chrome(service=service, options=chrome_options) self.driver.get("http://localhost:8000/notepad.html") # 确保这里的URL指向您的Web应用地址 self.driver.maximize_window() except Exception as e: print(f"Error initializing WebDriver: {e}") self.driver = None def teardown_method(self): if hasattr(self, 'driver') and self.driver is not None: self.driver.quit() def test_menu_items_exist(self): """Check if the menu items exist""" if self.driver is None: print("WebDriver is not initialized, skipping test.") return file_menu = self.driver.find_element(By.XPATH, "//span[text()='File']") edit_menu = self.driver.find_element(By.XPATH, "//span[text()='Edit']") assert file_menu.is_displayed() and edit_menu.is_displayed(), "Menu items do not exist." def test_open_file(self): """Test opening a file""" if self.driver is None: print("WebDriver is not initialized, skipping test.") return file_menu = self.driver.find_element(By.XPATH, "//span[text()='File']") file_menu.click() open_option = self.driver.find_element(By.XPATH, "//div[text()='Open']") open_option.click() time.sleep(2) # Wait for file dialog to appear # 假设这里有一个方法可以与文件对话框交互 def test_save_file(self): """Test saving a file""" if self.driver is None: print("WebDriver is not initialized, skipping test.") return file_menu = self.driver.find_element(By.XPATH, "//span[text()='File']") file_menu.click() save_option = self.driver.find_element(By.XPATH, "//div[text()='Save']") save_option.click() time.sleep(2) # Wait for save dialog to appear # 假设这里有一个方法可以与保存对话框交互 def test_cut_copy_paste(self): """Test cut, copy, paste functionality""" if self.driver is None: print("WebDriver is not initialized, skipping test.") return text_area = self.driver.find_element(By.TAG_NAME, 'textarea') text_area.send_keys("Hello, World!") text_area.send_keys(Keys.CONTROL, "a") edit_menu = self.driver.find_element(By.XPATH, "//span[text()='Edit']") edit_menu.click() cut_option = self.driver.find_element(By.XPATH, "//div[text()='Cut']") cut_option.click() text_area.send_keys(Keys.CONTROL, "v") assert text_area.get_attribute('value') == "Hello, World!", "Cut, copy, paste failed." if __name__ == "__main__": tester = TestNotepadUI() try: tester.setup_method() tester.test_menu_items_exist() tester.test_open_file() tester.test_save_file() tester.test_cut_copy_paste() finally: tester.teardown_method() ``` ### 关键改进点 1. **异常处理**:在`setup_method`中添加了异常处理,确保即使初始化失败,也不会影响`teardown_method`的执行。 2. **检查`driver`属性**:在每个测试方法和`teardown_method`中,先检查`self.driver`是否存在,避免`AttributeError`。 3. **日志输出**:当`WebDriver`未初始化时,输出日志信息,提醒测试被跳过。 ### 其他建议 - **使用`webdriver_manager`**:强烈建议使用`webdriver_manager`来自动管理ChromeDriver,这样可以避免路径配置问题。以下是使用`webdriver_manager`的示例: ```python from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from webdriver_manager.chrome import ChromeDriverManager import time class TestNotepadUI: def setup_method(self): try: # 设置Chrome浏览器路径 chrome_options = Options() chrome_options.binary_location = r"C:\Program Files\Google\Chrome\Application\chrome.exe" # 自动下载并配置ChromeDriver service = Service(ChromeDriverManager().install()) # 初始化WebDriver self.driver = webdriver.Chrome(service=service, options=chrome_options) self.driver.get("http://localhost:8000/notepad.html") # 确保这里的URL指向您的Web应用地址 self.driver.maximize_window() except Exception as e: print(f"Error initializing WebDriver: {e}") self.driver = None def teardown_method(self): if hasattr(self, 'driver') and self.driver is not None: self.driver.quit() def test_menu_items_exist(self): """Check if the menu items exist""" if self.driver is None: print("WebDriver is not initialized, skipping test.") return file_menu = self.driver.find_element(By.XPATH, "//span[text()='File']") edit_menu = self.driver.find_element(By.XPATH, "//span[text()='Edit']") assert file_menu.is_displayed() and edit_menu.is_displayed(), "Menu items do not exist." def test_open_file(self): """Test opening a file""" if self.driver is None: print("WebDriver is not initialized, skipping test.") return file_menu = self.driver.find_element(By.XPATH, "//span[text()='File']") file_menu.click() open_option = self.driver.find_element(By.XPATH, "//div[text()='Open']") open_option.click() time.sleep(2) # Wait for file dialog to appear # 假设这里有一个方法可以与文件对话框交互 def test_save_file(self): """Test saving a file""" if self.driver is None: print("WebDriver is not initialized, skipping test.") return file_menu = self.driver.find_element(By.XPATH, "//span[text()='File']") file_menu.click() save_option = self.driver.find_element(By.XPATH, "//div[text()='Save']") save_option.click() time.sleep(2) # Wait for save dialog to appear # 假设这里有一个方法可以与保存对话框交互 def test_cut_copy_paste(self): """Test cut, copy, paste functionality""" if self.driver is None: print("WebDriver is not initialized, skipping test.") return text_area = self.driver.find_element(By.TAG_NAME, 'textarea') text_area.send_keys("Hello, World!") text_area.send_keys(Keys.CONTROL, "a") edit_menu = self.driver.find_element(By.XPATH, "//span[text()='Edit']") edit_menu.click() cut_option = self.driver.find_element(By.XPATH, "//div[text()='Cut']") cut_option.click() text_area.send_keys(Keys.CONTROL, "v") assert text_area.get_attribute('value') == "Hello, World!", "Cut, copy, paste failed." if __name__ == "__main__": tester = TestNotepadUI() try: tester.setup_method() tester.test_menu_items_exist() tester.test_open_file() tester.test_save_file() tester.test_cut_copy_paste() finally: tester.teardown_method() ``` 通过使用`webdriver_manager`,您可以避免手动管理和配置ChromeDriver路径的问题。如果有任何疑问或遇到其他问题,请随时告知!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值