【问题标题】:How do you automatically open the Chrome Devtools within Selenium (VB.NET)?如何在 Selenium (VB.NET) 中自动打开 Chrome Devtools?
【发布时间】:2021-11-15 18:13:57
【问题描述】:

这就是我打开它的方式

运行

cd C:\Program Files\Google\Chrome\Application

chrome.exe --remote-debugging-port=9222 --user-data-dir="C:\API\localhost"

我的 VB.NET 代码不起作用

Dim options = New ChromeOptions()
        options.AddArgument("--start-maximized")
        options.AddArguments("disable-infobars")
        options.AddArguments("--disable-notifications")
        options.AddAdditionalCapability("debuggerAddress", "localhost:9222")
        Dim driver = New ChromeDriver("C:\API\chromedriver.exe", options)
        driver.get("https://ipleak.net/")

用 python 测试它可以工作,但我想要它用于 VB.NET

Python Code: 
from selenium import webdriver
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
from selenium.webdriver.chrome.options import Options



# configure chrome options
option = Options()
option.add_experimental_option("debuggerAddress","localhost:9222")
driver = webdriver.Chrome(executable_path = "C:\API\chromedriver.exe",options=option)

# open website
driver.get("https://ipleak.net/")

更新# 回复@Villa_7

我试过这个。由于某种原因没有工作我认为“PATH”代码是错误的

 Dim options = New ChromeOptions()
        options.AddArguments("--auto-open-devtools-for-tabs")
        Dim driver = New ChromeDriver("C:\API\chromedriver.exe",options)
        driver.Navigate().GoToUrl("https://ipleak.net")

当我将它设置为 PATH 时,Selenium 不运行:

Dim driver = New ChromeDriver("C:\API\chromedriver.exe", options)

只有当我这样运行时它才会运行:

Dim driver As IWebDriver = New ChromeDriver(options)

【问题讨论】:

    标签: vb.net selenium google-chrome localhost devtools


    【解决方案1】:

    试试这个 sn-p:

    Dim options = New ChromeOptions()
    options.AddArguments("--auto-open-devtools-for-tabs")
    

    【讨论】:

    • 阅读我的更新,我更新了帖子,有一些问题可能与路径有关,你能告诉我
    • 我想在我的本地 chrome 上的 VB.NET 上运行我的 selenium
    猜你喜欢
    • 2016-10-07
    • 1970-01-01
    • 2020-04-16
    • 2021-07-20
    • 2019-12-07
    • 2017-02-24
    • 1970-01-01
    • 2019-01-11
    • 1970-01-01
    相关资源
    最近更新 更多