如何解决'元素目前无法互动,可能无法操纵'为什么我的测试用例仍然可以通过

时间:2018-04-19 11:35:11

标签: selenium selenium-webdriver webdriver selenium-chromedriver katalon-studio

enter image description here

嗨,我正在使用katalon studio进行自动化测试。我为输入文本框设置了值,日志属性中的系统提示错误如下:

Unable to set text '1' of object 'Object Repository/Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/Page_Welcome to KAPPS Factoring Sys (1)/input_model.buyerProgramStages_10' (Root cause: org.openqa.selenium.InvalidElementStateException: invalid element state: Element is not currently interactable and may not be manipulated
  (Session info: chrome=65.0.3325.181)
  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'SGA1014', ip: '172.27.35.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.35.528161 (5b82f2d2aae0ca..., userDataDir: C:\Users\lixinyu\AppData\Lo...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 65.0.3325.181, webStorageEnabled: true}
Session ID: 2e27edd7304a30bc2cc431c849c9e4b7)

因此,我的测试用例的状态失败,但最终能够将值设置到文本框中。

有人能告诉我发生了什么吗?

我的剧本:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

WebUI.openBrowser('')

WebUI.maximizeWindow()

WebUI.navigateToUrl('http://sgsgaapp80:18093/dash/landing.do')

WebUI.setText(findTestObject('Test BuyerProg/Page_Login to Kapps System/input_j_username'), 'lixin')

WebUI.setText(findTestObject('Test BuyerProg/Page_Login to Kapps System/input_j_password'), 'kpmg@123')

WebUI.click(findTestObject('Test BuyerProg/Page_Login to Kapps System/input_btnLogin'))

WebUI.click(findTestObject('Test BuyerProg/Page_KPMG System/div_India'))

WebUI.click(findTestObject('Test BuyerProg/Page_FactorPro - Welcome to KAPPS F/td_function changeRequestLocal'))

WebUI.click(findTestObject('Test BuyerProg/Page_FactorPro - Welcome to KAPPS F/a_SUPPLIER FINANCE'))

WebUI.click(findTestObject('Test BuyerProg/Page_FactorPro - Welcome to KAPPS F/a_Static Entry'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/div_hitarea expandable-hitarea'))

WebUI.click(findTestObject('Object Repository/Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/Page_Welcome to KAPPS Factoring Sys/li_Buyer Program Entry'))

// WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/a_Buyer Program Entry'))
WebUI.selectOptionByValue(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/select_(ALL)    0AUTOBUY00 - 0'), 
    '0AUTOBUY00', true)

WebUI.selectOptionByValue(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/select_(ALL)    DB1 - DOM-Supp'), 
    'DB4', true)

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_form_2'))

WebUI.doubleClick(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.amo'))

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.amo'), 'Kevin Ng')

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerLimitID'), '9437523122C')

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.financeStage'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.financeStage_1'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.financeStage_2'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.financeStage_2'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/a_Indicators'))

WebUI.selectOptionByValue(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/select_Daily    Weekly    Mont'), 
    'W', true)

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.autoDebit'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.autoDebit_1'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_form_0'))

WebUI.selectOptionByValue(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/select_FIXED-TIER RATE'), 'M0', 
    true)

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages'), '5')

WebUI.selectOptionByValue(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/select_0 SBR (HKD)    1 USD LI'), 
    '9', true)

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages_1'), '2')

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages_2'), '30')

WebUI.selectOptionByValue(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/select_Document Date    Financ'), 
    'SFP001', true)

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages_3'), '20')

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages_4'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/a_Pre-acceptance'))

WebUI.selectOptionByValue(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/select_FIXED-TIER RATE_1'), 
    'M0', true)

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages'), '2')

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages_5'), '2')

WebUI.selectOptionByValue(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/select_0 SBR (HKD)    1 USD LI_1'), 
    '9', true)

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages_6'), '1')

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages_7'), '35')

WebUI.selectOptionByValue(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/select_Document Date    Financ_1'), 
    'SFP002', true)

WebUI.setText(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages_8'), '5')

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_model.buyerProgramStages_9'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_stage_0'))

WebUI.click(findTestObject('Test BuyerProg/Page_Welcome to KAPPS Factoring Sys/input_confirm_0'))

WebUI.waitForPageLoad(4)

String makerRef = new String()

makerRef = WebUI.getText(findTestObject('random/Page_Welcome to KAPPS Factoring Sys/span_Maker-Checker Ref  201712'))

println(('Required Maker Checker Reference should be as follows' + '\n') + makerRef)

String ref = makerRef.substring(20)

println(makerRef.substring(20))

WebUI.click(findTestObject('Test1_OR/Page_Welcome to KAPPS Factoring Sys/button_Logout'))

WebUI.closeBrowser(FailureHandling.CONTINUE_ON_FAILURE)

WebUI.callTestCase(findTestCase('SF 18093/checker-SF general'), [('makerReference') : ref], FailureHandling.STOP_ON_FAILURE)

我的舞台表格页面的html:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="k" uri="/extended-struts-tags"%>

<s:if test="%{model.csptProg!=null}">
    <s:url id="displayheader"
        action="/WEB-INF/pages/factorpro/_static/entry/buyerprogram/common/displayheader.jsp" />
    <s:include
        value="/WEB-INF/pages/factorpro/_static/entry/buyerprogram/common/displayheader.jsp" />
    <br />

    <div id="formDiv"><s:form action="stage" method="post"theme="kpmg_tabber">

        <s:url id="financestages"
            value="/WEB-INF/pages/factorpro/_static/entry/buyerprogram/common/form/financestages.jsp" />


        <s:url id="back" namespace="/createbuyerprogram" action="form" />


        <div class="tabber">
        <s:iterator value="model.buyerProgramStages" status="rowId">
            <div class="tabbertab">
            <h2><s:property value="stageName" /></h2>
            <s:include
                value="/WEB-INF/pages/factorpro/_static/entry/buyerprogram/common/form/financestages.jsp" />
            </div>
        </s:iterator>

        <%-- <div class="tabbertab">
        <h2><s:property value="%{getText('indicators')}" /></h2>
        <s:include
            value="/WEB-INF/pages/factorpro/_static/entry/buyerprogram/common/form/indicators.jsp" />
        </div> --%>

        </div>

        <s:if test="%{model.resubmitting}">
        <s:url id="owndashboard" namespace="%{dashboardnamespace}"
        action="%{dashboardaction}" />
        </s:if>

        <s:include value="/WEB-INF/pages/common/formparts/common.jsp" />
        <!-- For Maker checker Resubmit -->
        <s:include value="/WEB-INF/pages/common/workflow/resubmit-display-remarks.jsp" />
        <tr>
        <k:submit type="input" align="right" value="%{getText('submit')}"
            onclick="isCustomSubmit('stage','stage')" colspan="4" isfirst="true">
        </k:submit>
        <s:if test="%{model.resubmitting}">
            <k:submit type="input" align="right" value="%{getText('back')}"
                onclick="goto('%{owndashboard}');return false;"  islast="true" colspan="4">
            </k:submit>
        </s:if>
        <s:else>
            <k:submit value="%{getText('Previous Page')}" onclick="isBack('stage')" islast="true" colspan="4">
            </k:submit>
        </s:else>
        </tr>
    </s:form></div>
</s:if>
<s:else>
    <s:include value="/WEB-INF/pages/common/formparts/common.jsp" />
</s:else>

2 个答案:

答案 0 :(得分:1)

如果没有相关的代码试用和相关的 HTML ,很难调试异常/错误。但是,似乎存在如下问题:

这里的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:

  • 您正在使用 chromedriver = 2.35
  • chromedriver=2.35的发行说明明确提及以下内容:
  

支持 Chrome v62-64

  • 您正在使用 chrome = 65.0
  • ChromeDriver v2.37的发行说明明确提及以下内容:
  

支持 Chrome v64-66

因此 ChromeDriver 版本( v2.35 )与 Chrome浏览器版本( v65.0)之间明显不匹配

解决方案

  • ChromeDriver 升级到当前ChromeDriver v2.37级别。
  • Chrome 版本保留在 Chrome v65.x 级别。 (as per ChromeDriver v2.37 release notes
  • 通过 IDE 清理您的项目工作区仅使用所需的依赖项重建项目
  • 使用CCleaner工具清除执行测试套件之前和之后的所有操作系统杂务。
  • 如果您的基本 Web客户端版本太旧,请通过Revo Uninstaller将其卸载并安装最新的GA和已发布的 Web客户端版本。
  • 进行系统重启
  • 执行@Test

你是如何逃脱的

虽然您遇到了 org.openqa.selenium.InvalidElementStateException ,但您的测试已经过时KATALON STUDIO设法使会话保持活动状态并且您已经完成了。

答案 1 :(得分:0)

在显示错误的元素之前,将以下行添加到脚本中。

WebUI.delay(3)

对我有用。