【问题标题】:Phantomjs in handling onclick events using ruby-seleniumPhantomjs 使用 ruby​​-selenium 处理 onclick 事件
【发布时间】:2016-12-24 18:13:44
【问题描述】:
<INPUT onclick="return verifyCheckedForEdit('UserAdminForm', 'itemDelUserId','hiddenUserId', 'Disable')" id=disableButton class=buttonBlue type=submit value=Disable name=Disable>

以上是我的标签。我尝试了各种选项:

disable=$driver.find_element(:xpath,"html/body/div[4]/div[1]/div[2]/form/table/tbody/tr[2]/td/input[2]")
  • disable.submit
  • $driver.find_element(:name,"Disable").send_keys :enter
  • $driver.action.move_to(disable).double_click(disable).perform
  • $driver.action.move_to(disable).click(disable).perform

以上都不能点击这个按钮。

【问题讨论】:

    标签: javascript html ruby selenium


    【解决方案1】:

    点击后我正在截屏,但是我注意到截屏没有使用 phantom js 的模态窗口:

    我尝试最大化屏幕: $driver.manage.window.maximize

    然后我尝试单击窗口上的确认。但是什么也没有发生。所以我不知道 phantomjs 是否真的呈现了模态窗口,并且它实际上是否点击了模态弹出窗口。

    如果有人需要,我找到了解决方案:

    $driver.execute_script('window.alert = function(){};')
    $driver.execute_script('window.confirm = function(confirmationText) {return true; };')
    delete=$driver.find_element(:name,"Delete").click
    

    在您点击禁用/删除按钮之前,请创建一个模态窗口,然后点击它。

    【讨论】:

      猜你喜欢
      • 2015-05-13
      • 1970-01-01
      • 1970-01-01
      • 2014-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多