简体   繁体   English

如何在 selenimum webdriver URL 中传递参数

[英]How to pass arguments in selenimum webdriver URL

I am trying to pass node_name as an argument for the below command.我正在尝试将 node_name 作为以下命令的参数传递。 My code is:我的代码是:

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

I am using selenium+Python+chromedriver here.我在这里使用 selenium+Python+chromedriver。 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. execute_script()的第一个参数是包含要执行的脚本的字符串。 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.每个下一个参数都作为参数传递给脚本,并且可以通过使用引用参数数组的arguments[]变量在脚本中访问。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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