isaiah day
isaiah day

Reputation: 55

How to execute console commands in browser with selenium

Is there a way to execute console commands in browser with selenium? (The browser type is of no importance.)

Here is an example:

console in firefox

Upvotes: 1

Views: 4639

Answers (1)

Cesar Lopes
Cesar Lopes

Reputation: 413

Executing commands in the Chrome console for the most part is simply executing javascript code.

Here is a sample:

from selenium import webdriver

path = 'Path to ChromeDriver executable'
driver = webdriver.Chrome(path)
#navigate to the url
driver.get("https://google.com")
#execute console command
driver.execute_script("date1 = '13-11-2015T17:25'; date2 = '25-11-2015T11:01';")

Here is the result: Result

Upvotes: 3

Related Questions