I want to make a fetch call fetch("https://www.test.com")
in chrome dev tools console.
--auto-open-devtools-for-tabs
opens the dev tools. However, I'm not sure if it is possible to navigate to console
and type fetch("https://www.test.com")
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--auto-open-devtools-for-tabs')
driver = webdriver.Chrome(seleniumwire_options={'verify_ssl': False},
executable_path=ChromeDriverManager(chrome_type='google-chrome').install(),
chrome_options=chrome_options
)
Executing commands in the Chrome console for the most part is simply executing JavaScript code. then you could just execute like follows in Selenium:
driver.execute_script("fetch('https://www.test.com'")
if you needed to see the returned value of a command since you are using headless mode then it could be something like:
print(self.driver.execute_script("fetch('https://www.test.com')"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.