Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将带有send_keys()的变量传递到警报确认弹出窗口_Python_Selenium_Selenium Webdriver_Popup_Prompt - Fatal编程技术网

Python 将带有send_keys()的变量传递到警报确认弹出窗口

Python 将带有send_keys()的变量传递到警报确认弹出窗口,python,selenium,selenium-webdriver,popup,prompt,Python,Selenium,Selenium Webdriver,Popup,Prompt,selenium出现错误,将带有send_keys()的变量传递到警报确认弹出窗口。下面是简化的代码(a1和a2是整数变量) 在最后一行我得到了以下错误 TypeError:“int”对象不可编辑 当我尝试用driver.switch_至.alert.send_键(“abcd”)传递某个字符串时,它工作得非常好 有人能解释一下为什么它在第一个send_键上工作而在第二个上不工作吗?调用send_键()时,将整数int(av)转换为字符串,如下所示: driver.switch_to.alert.

selenium出现错误,将带有send_keys()的变量传递到警报确认弹出窗口。下面是简化的代码(a1和a2是整数变量)

在最后一行我得到了以下错误

TypeError:“int”对象不可编辑

当我尝试用driver.switch_至.alert.send_键(“abcd”)传递某个字符串时,它工作得非常好


有人能解释一下为什么它在第一个send_键上工作而在第二个上不工作吗?

调用
send_键()
时,将整数
int(av)
转换为字符串,如下所示:

driver.switch_to.alert.send_keys(str(int(av)))

driver.切换到.alert.发送按键(str(av))
试试这个
driver.switch_to.alert.send_keys(str(int(av)))