无法在Katalon Studio上执行点击

时间:2018-09-19 04:43:45

标签: xpath automation click katalon-studio

问题 我是Katalon和自动化测试的新手,我尝试了所有操作,但无法执行简单按钮的点击功能

我的代码也没有失败,但是在页面上没有执行点击功能

网页 https://www.ratesupermarket.ca/term_life_insurance

HTML
 获取报价

xpath // button [@ id ='submit']

脚本代码 WebUI.openBrowser('') “转到URL” WebUI.navigateToUrl('https://www.ratesupermarket.ca/term_life_insurance') “输入邮政编码-转到下一页” WebUI.setText(findTestObject('对象存储库/费率页1 / Page_Life Insurance比较/ input_postal_code'),'M12W22') WebUI.click(findTestObject('对象存储库/费率页面1 / Page_Life Insurance比较/ button_Get Quotes'))

控制台日志

09-19-2018 12:58:17 PM - [START]  - Start Test Case : Test Cases/Perform click and Get Quote
09-19-2018 12:58:17 PM - [INFO]   - Evaluating variables for test case
09-19-2018 12:58:18 PM - [START]  - Start action : openBrowser
09-19-2018 12:58:18 PM - [INFO]   - Opening browser
09-19-2018 12:58:18 PM - [INFO]   - Starting 'IE' driver
09-19-2018 12:58:18 PM - [INFO]   - Action delay is set to 0 seconds
Started InternetExplorerDriver server (32-bit)
3.6.0.0
Listening on port 2893
Log level is set to TRACE
Log file is set to C:\Users\cnawork\AppData\Local\Temp\Katalon\Test Cases\Perform click and Get Quote\20180919_125813\IEDriverServer.log
Only local connections are allowed
Sep 19, 2018 12:58:21 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
09-19-2018 12:58:21 PM - [RUN_DATA] - Logging run data 'sessionId' with value '50bd252d-7549-4b1a-9a8c-d9fa80318749'
09-19-2018 12:58:21 PM - [RUN_DATA] - Logging run data 'browser' with value 'IE 11'
09-19-2018 12:58:21 PM - [RUN_DATA] - Logging run data 'platform' with value 'Windows 8.1'
09-19-2018 12:58:21 PM - [RUN_DATA] - Logging run data 'seleniumVersion' with value '3.7.1'
09-19-2018 12:58:21 PM - [RUN_DATA] - Logging run data 'proxyInformation' with value 'ProxyInformation{proxyOption=NO_PROXY, proxyServerType=HTTP, password=, proxyServerAddress=, proxyServerPort=0}'
09-19-2018 12:58:21 PM - [PASSED] - Browser is opened with url: ''
09-19-2018 12:58:21 PM - [END]    - End action : openBrowser
09-19-2018 12:58:21 PM - [START]  - Start action : navigateToUrl
09-19-2018 12:58:21 PM - [INFO]   - Checking url
09-19-2018 12:58:21 PM - [INFO]   - Navigating to 'https://www.ratesupermarket.ca/term_life_insurance'
09-19-2018 12:58:27 PM - [PASSED] - Navigate to 'https://www.ratesupermarket.ca/term_life_insurance' successfully
09-19-2018 12:58:27 PM - [END]    - End action : navigateToUrl
09-19-2018 12:58:27 PM - [START]  - Start action : setText
09-19-2018 12:58:27 PM - [INFO]   - Finding Test Object with id 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/input_postal_code'
09-19-2018 12:58:27 PM - [INFO]   - Checking object
09-19-2018 12:58:27 PM - [INFO]   - Checking text
09-19-2018 12:58:27 PM - [INFO]   - Checking timeout
09-19-2018 12:58:27 PM - [INFO]   - Finding web element with id: 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/input_postal_code' located by 'By.xpath: //input[@id='postal_code']' in '30' second(s)
09-19-2018 12:58:27 PM - [INFO]   - Found 1 web elements with id: 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/input_postal_code' located by 'By.xpath: //input[@id='postal_code']' in '30' second(s)
09-19-2018 12:58:27 PM - [INFO]   - Clearing text of object 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/input_postal_code'
09-19-2018 12:58:27 PM - [INFO]   - Checking timeout
09-19-2018 12:58:27 PM - [INFO]   - Finding web element with id: 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/input_postal_code' located by 'By.xpath: //input[@id='postal_code']' in '30' second(s)
09-19-2018 12:58:27 PM - [INFO]   - Found 1 web elements with id: 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/input_postal_code' located by 'By.xpath: //input[@id='postal_code']' in '30' second(s)
09-19-2018 12:58:27 PM - [INFO]   - Setting text of object 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/input_postal_code' to value 'M12W22'
09-19-2018 12:58:27 PM - [PASSED] - Text 'M12W22' is set on object 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/input_postal_code'
09-19-2018 12:58:27 PM - [END]    - End action : setText
09-19-2018 12:58:27 PM - [START]  - Start action : click
09-19-2018 12:58:27 PM - [INFO]   - Finding Test Object with id 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/button_Get Quotes'
09-19-2018 12:58:27 PM - [INFO]   - Checking object
09-19-2018 12:58:27 PM - [INFO]   - Checking timeout
09-19-2018 12:58:27 PM - [INFO]   - Finding web element with id: 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/button_Get Quotes' located by 'By.xpath: //button[@id='submit']' in '30' second(s)
09-19-2018 12:58:28 PM - [INFO]   - Found 1 web elements with id: 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/button_Get Quotes' located by 'By.xpath: //button[@id='submit']' in '30' second(s)
09-19-2018 12:58:28 PM - [INFO]   - Clicking on object: 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/button_Get Quotes'
09-19-2018 12:58:29 PM - [PASSED] - Object: 'Object Repository/Rates Page 1/Page_Life Insurance Comparison/button_Get Quotes' is clicked on
09-19-2018 12:58:29 PM - [END]    - End action : click
09-19-2018 12:58:29 PM - [PASSED] - Test Cases/Perform click and Get Quote
09-19-2018 12:58:29 PM - [END]    - End Test Case : Test Cases/Perform click and Get Quote

2 个答案:

答案 0 :(得分:0)

尝试使用此关键字:

@Keyword
def clickUsingJS(TestObject to, int timeout)
{ 
    WebDriver driver = DriverFactory.getWebDriver()
    WebElement element = WebUICommonHelper.findWebElement(to, timeout)
    JavaScriptExecutor executor = ((driver)as  JavaScriptExecutor)
    executor.executeScript('arguments[0].click()',element)
}

答案 1 :(得分:0)

在katalon中有一个WebUI元素,称为“等待元素可见”。希望使用此元素,它将对您有用。