简体   繁体   English

Selenium Chrome驱动程序:单击功能的Javascript。 元素不可见或没有任何反应

[英]Selenium Chrome Driver: Javascript on click function. element not visible or nothing happens

So I'm working on a script at work that automates VMWare's Airwatch token generation for MDM. 因此,我正在研究一个脚本,该脚本可自动为MDM生成VMWare的Airwatch令牌。 It was functioning, but they updated the server/Airwatch Console and this javascript onclick function broke it. 它正在运行,但是他们更新了服务器/ Airwatch控制台,并且此javascript onclick函数将其破坏了。 I've already searched through various forums and posts and have no luck getting it to work. 我已经搜索了各种论坛和帖子,但运气不佳。 If I have selenium find the element and .click() on it, I get the not visible/not interactable error. 如果我有硒找到元素并在其上单击.click(),则会收到不可见/不可交互的错误。 Currently, I have: 目前,我有:

addButton=driver.find_element_by_css_selector("a.add.profile.small")
webdriver.ActionChains(driver).move_to_element(addButton).perform().click(addButton)

And no errors occur but it doesn't do anything. 并且没有错误发生,但是它什么也没做。

When manually moving the mouse over the button it changes to a hand instead of the pointer and the button background color changes. 当手动将鼠标移到按钮上时,它将变为手形而不是指针,并且按钮的背景色也会改变。

Here's a snippet of the element properties: 这是元素属性的片段:

        <a class="add profile small" onclick="F5_r2u();F5_Event_common(event);
    try{return(eval(F5_Invoke_eval_event(null,F5_jsBody(function(){addTagRow(this);
        }))))}finally{try{F5_Event_finally(event)}catch(e){}}">Add</a>

selector: #\31 34364e7_Tag_Plural > a
xpath: //*[@id="134364e7_Tag_Plural"]/a

Any Advice? 有什么建议吗?

Pretty sure I need to have Selenium hover over the button, then click on it, or execute the javascript. 相当确定我需要将Selenium悬停在按钮上,然后单击它或执行javascript。 Not sure how to do that though. 虽然不知道如何做到这一点。

Screenshot of Add Button 添加按钮的屏幕截图

when you switch from tab User to Tags it need to wait until ADD button visible 当您从“ User Tags切换到“ Tags ,需要等到可见“ ADD按钮

# click tab Tags
tabTags = driver.find_element_by_css_selector('tab.tags.selector').click()
# wait until visible
addButton = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'a.add.profile.small')))
addButton.click()

using ActionChains maybe like this 使用ActionChains可能像这样

tabTags = driver.find_element_by_css_selector('tab.tags.selector')
addButton = driver.find_element_by_css_selector("a.add.profile.small")

actions = webdriver.ActionChains(driver)
actions.click(tabTags)
actions.click(addButton)
actions.perform()

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

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