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
无法单击";“保存”;按钮(SeleniumWebDriver-python-chrome)_Python_Selenium_Xpath - Fatal编程技术网

无法单击";“保存”;按钮(SeleniumWebDriver-python-chrome)

无法单击";“保存”;按钮(SeleniumWebDriver-python-chrome),python,selenium,xpath,Python,Selenium,Xpath,我对Python相当陌生,并开始学习。我正在尝试自动化数据输入。我被“保存”按钮卡住了。如何找到正确的信息并单击以保存 多谢各位 皮盖 元素 <input type="submit" value="Save"> 选择器 #decorated-admin-content > div > div > form > div.buttons-container > div > input[type="submit"] 在我的python脚本中,我已

我对Python相当陌生,并开始学习。我正在尝试自动化数据输入。我被“保存”按钮卡住了。如何找到正确的信息并单击以保存

多谢各位

皮盖


元素

<input type="submit" value="Save">
选择器

#decorated-admin-content > div > div > form > div.buttons-container > div > input[type="submit"]

在我的python脚本中,我已经输入了

from selenium import webdriver
from selenium.webdriver.common.by import By

driver.findElement(By.xpath("//input[@type='submit'and @value='save']")).click()
# I also tried below
# driver.findElement(By.xpath("//input[@type='submit'][@value='Save']")).click();
# driver.findElement(By.xpath("//*[@id="decorated-admin-content"]"))

是否尝试使用xpath以外的其他参数? 我在使用selenium时也遇到了一些困难,您可以尝试以下方法:

driver.findElement(By.tagName("form")).submit()

它对我来说很有用,可以验证表单

除了xpath之外,您还尝试过其他参数吗? 我在使用selenium时也遇到了一些困难,您可以尝试以下方法:

driver.findElement(By.tagName("form")).submit()

它对我来说很有用,可以验证表单

如果您使用的是python,语法不正确。Python使用snake_大小写,By使用常量约定

from selenium import webdriver
from selenium.webdriver.common.by import By

driver.find_element(By.XPATH, "//input[@type='submit' and @value='save']").click()
实际上,如果您不需要是动态的,建议您为每个人使用单独的方法:

driver.find_element_by_xpath("//input[@type='submit' and @value='save']").click()
或css:

driver.find_element_by_css_selector('input[type="submit"]').click()

如果这不起作用,您可以发布您得到的错误回溯吗?

如果您使用的是python,语法不正确。Python使用snake_大小写,By使用常量约定

from selenium import webdriver
from selenium.webdriver.common.by import By

driver.find_element(By.XPATH, "//input[@type='submit' and @value='save']").click()
实际上,如果您不需要是动态的,建议您为每个人使用单独的方法:

driver.find_element_by_xpath("//input[@type='submit' and @value='save']").click()
或css:

driver.find_element_by_css_selector('input[type="submit"]').click()

如果这不起作用,您可以发布您得到的错误回溯吗?

非常感谢!CSS的工作原理是:驱动程序。通过CSS选择器('input[type=“submit”]”)查找元素。单击()非常感谢!CSS的工作原理是:驱动程序。通过_CSS_选择器('input[type=“submit”]”)查找_元素。单击()