简体   繁体   English

Python Selenium WebElement 元素 = 无效语法

[英]Python Selenium WebElement element = invalid syntax

I have this python code for Selenium but I have "invalid syntax" highligthing element whenever I run it.我有这个用于 Selenium 的 python 代码,但是每当我运行它时我都会有“无效语法”高亮元素

{
WebElement element = driver.find_element_by_link_text("Cancel")
actions builder = ActionChains(driver)
builder.move_to_element(element)
element.perform
}

perform()履行()

perform() performs all stored actions sequentially. perform()顺序执行所有存储的操作。

Additionally, can initialize and assign data types automatically so you don't have to explicitly mention them.此外, 可以自动初始化和分配数据类型,因此您不必明确提及它们。

To invoke perform() on the element you can use the following solution:要在元素上调用perform() ,您可以使用以下解决方案:

from selenium.webdriver.common.action_chains import ActionChains

element = driver.find_element_by_link_text("Cancel")
builder = ActionChains(driver)
builder.move_to_element(element).perform()

As an alternative, you can use the following line of code:作为替代方案,您可以使用以下代码行:

from selenium.webdriver.common.action_chains import ActionChains

ActionChains(driver).move_to_element(driver.find_element_by_link_text("Cancel")).perform()

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

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