简体   繁体   中英

How to pass arguments in selenimum webdriver URL

I am trying to pass node_name as an argument for the below command. My code is:

driver.execute_script("window.open('https://test.test.com/comp/node_name:abc');")

I am using selenium+Python+chromedriver here. I tried with the below command but no luck

driver.execute_script("window.open('https://test.test.com/comp/node_name:sys.argv[1]');")

The first argument of execute_script() is the string containing the script that you want to execute. Every next argument is passed on the script as an argument, and can be accessed within the script by using the arguments[] variable which refers to an array of arguments.

driver.execute_script("window.open('https://test.test.com/comp/node_name:' + arguments[0]);", node_name)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM