标签: seleniumwire

selenium / seleniumwire 未知错误:无法从未知错误确定加载状态:意外的命令响应

这是错误:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot determine loading status
from unknown error: unexpected command response
  (Session info: chrome=103.0.5060.53)
Run Code Online (Sandbox Code Playgroud)

我正在使用正确的网络驱动程序和 chrome 版本:

这是脚本,它的工作是从普通用户数据目录打开网页并提供响应。

from seleniumwire import webdriver  # Import from seleniumwire


chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-data-dir=C:\\selenium") 

driver = webdriver.Chrome(chrome_options=chrome_options)

driver.get('https://katalon.com/
')


for request in driver.requests:
    if request.response:
        print(
            
            request.response.status_code,
            
        )
Run Code Online (Sandbox Code Playgroud)

python selenium selenium-webdriver seleniumwire

35
推荐指数
5
解决办法
4万
查看次数

Selenium-wire 响应对象 - 以字符串而不是字节形式获取响应主体的方法

我想以 selenium-wire 中的字符串形式获取响应主体,最终将其解析为 JSON。

response.body在 selenium-wire 中给出字节字符串。我尝试解码它,response.body.decode('utf-8')但这给出了解码错误。

有人可以帮我弄这个吗?我对这两种解决方案都很好:

  1. 将字节字符串解码为普通字符串的方法
  2. 首先将响应正文作为普通字符串获取的方法

selenium response httpresponse utf-8 seleniumwire

7
推荐指数
2
解决办法
9574
查看次数

由于代理配置,硒线阻塞连接

我正在使用 selenium-wire 和 firefox webdriver 访问网站(在线游戏)。我在本地网络上运行 python 脚本,不需要代理来访问 Internet。

这是我的代码的摘录:

#!C:/Python38-32/python.exe
    
from seleniumwire import webdriver  # Import from seleniumwire
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains

# Create a new instance of the Firefox driver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary(r'C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)

# Go to the home page
driver.get('https://fr0.forgeofempires.com/page/')

iframe = driver.find_element_by_tag_name('iframe')
iframe_switched = driver.switch_to.frame(iframe)
    
useridInput = driver.find_element_by_id('login_userid')
useridInput.click();
    
useridInput.send_keys('myuser'); 

login_passwordInput = driver.find_element_by_id('login_password')
login_passwordInput.click(); …
Run Code Online (Sandbox Code Playgroud)

firefox proxy webdriver seleniumwire

5
推荐指数
1
解决办法
3071
查看次数