How to execute a Javascript function in python with selenium

前端 未结 2 2062
花落未央
花落未央 2020-12-08 23:15

I have a function called \'checkdata(code)\' in javascript, which, as you can see, takes an argument called \'code\' to run and returns a 15-char string.

So, I found

2条回答
  •  不知归路
    2020-12-08 23:55

    Rather than building a string (which means you'd have to escape your quotes properly), try this:

    a = wd.execute_script("return checkdata(arguments[0])", code)
    

提交回复
热议问题