提问人:sapkodas 提问时间:10/16/2023 更新时间:10/16/2023 访问量:32
Python Selenium metamask 自动化错误
Python Selenium metamask automation error
问:
我正在尝试在网站上自动登录 metamask(加密钱包扩展),但在尝试查找密码输入元素时出现错误。我已经设法想出了一个修复方法,但我不明白为什么它以前不起作用。 这篇文章介绍了这个错误,但在不同的上下文中:Runtime.callFunctionOn 抛出异常:错误:LavaMoat - globalThis 的属性“代理”在凿沉模式下无法访问。
非工作代码:
window_handles = driver.window_handles
button_metamask = wait.until(EC.element_to_be_clickable((By.XPATH, '//button[(@data-testid="rk-wallet-option-metaMask")]')))
button_metamask.click()
time.sleep(5)
wait.until(EC.new_window_is_opened(window_handles))
main_window = driver.current_window_handle
driver.switch_to.window(driver.window_handles[-1])
#exception thrown here v
inp = wait.until(EC.presence_of_element_located((By.XPATH, '//input')))
Message: unknown error: Runtime.callFunctionOn threw exception: Error: LavaMoat - property "Proxy" of globalThis is inaccessible under scuttling mode. To learn more visit https://github.com/LavaMoat/LavaMoat/pull/360.
工作代码:
window_handles = driver.window_handles
button_metamask = wait.until(EC.element_to_be_clickable((By.XPATH, '//button[(@data-testid="rk-wallet-option-metaMask")]')))
#this opens metamask
button_metamask.click()
wait.until(EC.new_window_is_opened(window_handles))
time.sleep(5)
main_window = driver.current_window_handle
#switch to metamask window
driver.switch_to.window(driver.window_handles[-1])
inp = wait.until(EC.presence_of_element_located((By.XPATH, '//input')))
我所做的只是改变 的位置。我不一定需要 time.sleep(5),它只是一个示例,但是,相反,我需要等待主窗口上的另一个元素,然后再切换到 metamask 弹出窗口。为什么一个位置会引起这样的例外?我也尝试使用另一个,但没有用。time.sleep(5)
time.sleep()
EC.number_of_windows_to_be(window_handles+1)
答: 暂无答案
评论