Selenium webdriver 卡塔隆工作室弹出元素标识

Selenium webdriver 卡塔隆工作室弹出元素标识,selenium-webdriver,webdriver,frame,katalon-studio,katalon-recorder,Selenium Webdriver,Webdriver,Frame,Katalon Studio,Katalon Recorder,我面临的以下问题可能是由于我对塞勒涅斯语缺乏了解。这是我第一次使用Katalon Studio,我对我面临的问题感到非常困惑,因为它似乎在Katalon Recorder上工作,但导出的脚本在Studio上不工作。我很确定我需要更改代码,但我不知道要更改什么 以下关于我的问题的细节摘自我在卡塔隆论坛上的早期帖子,该帖子有截图帮助澄清我的描述。您可以通过以下链接找到我的查询: 无法识别弹出窗体 我正在公司网站上自动生成一份注册表格 表单中有一部分需要单击“添加总部地址”按钮 这将打开一个弹出窗口(

我面临的以下问题可能是由于我对塞勒涅斯语缺乏了解。这是我第一次使用Katalon Studio,我对我面临的问题感到非常困惑,因为它似乎在Katalon Recorder上工作,但导出的脚本在Studio上不工作。我很确定我需要更改代码,但我不知道要更改什么

以下关于我的问题的细节摘自我在卡塔隆论坛上的早期帖子,该帖子有截图帮助澄清我的描述。您可以通过以下链接找到我的查询:

无法识别弹出窗体

我正在公司网站上自动生成一份注册表格

表单中有一部分需要单击“添加总部地址”按钮

这将打开一个弹出窗口(我认为它被称为模式窗口),其中将输入更多数据:

我使用的Selenium Studio 5.4.1无法关注这个新窗口,并继续说找不到相应的ID或索引

为了供您参考,我使用Katalon Recorder IDE Chrome扩展插件录制了填写此表单的过程,然后将脚本导出为适用于Katalon Studio的selenese语言

selenium.click('id=_application_portlet_WAR_morcmsportlet_btnAddHQAddress')
selenium.selectFrame('index=0')
selenium.click('id=_application_portlet_WAR_morcmsportlet_postalTx')
错误发生在“index=0”行

这是控制台日志:

> `05-17-2018 04:32:39 PM - [START]  - Start Test Case : Test Cases/New Test Case 1
05-17-2018 04:32:39 PM - [INFO]   - Evaluating variables for test case
05-17-2018 04:32:40 PM - [START]  - Start action : openBrowser
05-17-2018 04:32:41 PM - [INFO]   - Opening browser
05-17-2018 04:32:41 PM - [INFO]   - Starting 'Chrome' driver
05-17-2018 04:32:41 PM - [INFO]   - Action delay is set to 0 seconds
Starting ChromeDriver 2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73) on port 3131
Only local connections are allowed.
May 17, 2018 4:32:51 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
05-17-2018 04:33:12 PM - [RUN_DATA] - Logging run data 'sessionId' with value '6ea4d9fdedc35b6cbe8830fc3aa58d10'
05-17-2018 04:33:12 PM - [RUN_DATA] - Logging run data 'browser' with value 'Chrome 66.0.3359.139'
05-17-2018 04:33:12 PM - [RUN_DATA] - Logging run data 'platform' with value 'Windows 7'
05-17-2018 04:33:12 PM - [RUN_DATA] - Logging run data 'seleniumVersion' with value '3.7.1'
05-17-2018 04:33:12 PM - [RUN_DATA] - Logging run data 'proxyInformation' with value 'ProxyInformation{proxyOption=USE_SYSTEM, proxyServerType=HTTP, password=, proxyServerAddress=, proxyServerPort=0}'
05-17-2018 04:33:12 PM - [INFO]   - Navigating browser to: 'https://mo-uat.nets.com.sg/group/main'
05-17-2018 04:33:16 PM - [PASSED] - Browser is opened with url: 'https://mo-uat.nets.com.sg/group/main'
05-17-2018 04:33:16 PM - [END]    - End action : openBrowser
05-17-2018 04:33:16 PM - [START]  - Start action : Statement - java.lang.System.setProperty("webdriver.chrome.driver", "C:\Users\vilvamanggkhai\Documents\Stuidio\chromedriver.exe")
05-17-2018 04:33:16 PM - [END]    - End action : Statement - java.lang.System.setProperty("webdriver.chrome.driver", "C:\Users\vilvamanggkhai\Documents\Stuidio\chromedriver.exe")
05-17-2018 04:33:16 PM - [START]  - Start action : Statement - driver = com.kms.katalon.core.webui.driver.DriverFactory.getWebDriver()
05-17-2018 04:33:16 PM - [END]    - End action : Statement - driver = com.kms.katalon.core.webui.driver.DriverFactory.getWebDriver()
05-17-2018 04:33:16 PM - [START]  - Start action : Statement - baseUrl = "https://mo-uat.nets.com.sg/group/main"
05-17-2018 04:33:16 PM - [END]    - End action : Statement - baseUrl = "https://mo-uat.nets.com.sg/group/main"
05-17-2018 04:33:16 PM - [START]  - Start action : Statement - selenium = new com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium(driver, baseUrl)
05-17-2018 04:33:16 PM - [END]    - End action : Statement - selenium = new com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium(driver, baseUrl)
05-17-2018 04:33:16 PM - [START]  - Start action : Statement - selenium.click("id=_58_login")
05-17-2018 04:33:16 PM - [END]    - End action : Statement - selenium.click("id=_58_login")
05-17-2018 04:33:16 PM - [START]  - Start action : Statement - selenium.type("id=_58_login", "css.verifier1")
05-17-2018 04:33:16 PM - [END]    - End action : Statement - selenium.type("id=_58_login", "css.verifier1")
05-17-2018 04:33:16 PM - [START]  - Start action : Statement - selenium.click("id=_58_password")
05-17-2018 04:33:16 PM - [END]    - End action : Statement - selenium.click("id=_58_password")
05-17-2018 04:33:16 PM - [START]  - Start action : Statement - selenium.type("id=_58_password", "P@ssw0rd")
05-17-2018 04:33:16 PM - [END]    - End action : Statement - selenium.type("id=_58_password", "P@ssw0rd")
05-17-2018 04:33:16 PM - [START]  - Start action : Statement - selenium.click("//button[@type='submit']")
05-17-2018 04:33:23 PM - [END]    - End action : Statement - selenium.click("//button[@type='submit']")
05-17-2018 04:33:23 PM - [START]  - Start action : Statement - selenium.open("https://mo-uat.nets.com.sg/group/main/create-application")
05-17-2018 04:33:25 PM - [END]    - End action : Statement - selenium.open("https://mo-uat.nets.com.sg/group/main/create-application")
05-17-2018 04:33:25 PM - [START]  - Start action : Statement - selenium.open("https://mo-uat.nets.com.sg/group/main/create-application?p_p_id=application_portlet_WAR_morcmsportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_application_portlet_WAR_morcmsportlet_showTab=Application&_application_portlet_WAR_morcmsportlet_render=createAppLoadCustomer")
05-17-2018 04:33:26 PM - [END]    - End action : Statement - selenium.open("https://mo-uat.nets.com.sg/group/main/create-application?p_p_id=application_portlet_WAR_morcmsportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_application_portlet_WAR_morcmsportlet_showTab=Application&_application_portlet_WAR_morcmsportlet_render=createAppLoadCustomer")
05-17-2018 04:33:26 PM - [START]  - Start action : Statement - selenium.type("id=_application_portlet_WAR_morcmsportlet_custIdNo", "oijl78g84")
05-17-2018 04:33:26 PM - [END]    - End action : Statement - selenium.type("id=_application_portlet_WAR_morcmsportlet_custIdNo", "oijl78g84")
05-17-2018 04:33:26 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_custIdType")
05-17-2018 04:33:26 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_custIdType")
05-17-2018 04:33:26 PM - [START]  - Start action : Statement - selenium.select("id=_application_portlet_WAR_morcmsportlet_custIdType", "label=ACRA")
05-17-2018 04:33:27 PM - [END]    - End action : Statement - selenium.select("id=_application_portlet_WAR_morcmsportlet_custIdType", "label=ACRA")
05-17-2018 04:33:27 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_custIdType")
05-17-2018 04:33:27 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_custIdType")
05-17-2018 04:33:27 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_btnProceed")
05-17-2018 04:33:30 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_btnProceed")
05-17-2018 04:33:30 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_salesConsultantCd")
05-17-2018 04:33:30 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_salesConsultantCd")
05-17-2018 04:33:30 PM - [START]  - Start action : Statement - selenium.select("id=_application_portlet_WAR_morcmsportlet_salesConsultantCd", "label=VALERIE CHEE HSIN YEE")
05-17-2018 04:33:31 PM - [END]    - End action : Statement - selenium.select("id=_application_portlet_WAR_morcmsportlet_salesConsultantCd", "label=VALERIE CHEE HSIN YEE")
05-17-2018 04:33:31 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_salesConsultantCd")
05-17-2018 04:33:31 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_salesConsultantCd")
05-17-2018 04:33:31 PM - [START]  - Start action : Statement - selenium.click("Xpath=//*[contains(text(),' Profile ')]")
05-17-2018 04:33:31 PM - [END]    - End action : Statement - selenium.click("Xpath=//*[contains(text(),' Profile ')]")
05-17-2018 04:33:31 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_custNameTx")
05-17-2018 04:33:31 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_custNameTx")
05-17-2018 04:33:31 PM - [START]  - Start action : Statement - selenium.type("id=_application_portlet_WAR_morcmsportlet_custNameTx", "company name")
05-17-2018 04:33:31 PM - [END]    - End action : Statement - selenium.type("id=_application_portlet_WAR_morcmsportlet_custNameTx", "company name")
05-17-2018 04:33:31 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_businessTypeCd")
05-17-2018 04:33:32 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_businessTypeCd")
05-17-2018 04:33:32 PM - [START]  - Start action : Statement - selenium.select("id=_application_portlet_WAR_morcmsportlet_businessTypeCd", "label=PTE LTD")
05-17-2018 04:33:32 PM - [END]    - End action : Statement - selenium.select("id=_application_portlet_WAR_morcmsportlet_businessTypeCd", "label=PTE LTD")
05-17-2018 04:33:32 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_businessTypeCd")
05-17-2018 04:33:32 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_businessTypeCd")
05-17-2018 04:33:32 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_custDt_corp")
05-17-2018 04:33:33 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_custDt_corp")
05-17-2018 04:33:33 PM - [START]  - Start action : Statement - selenium.type("id=_application_portlet_WAR_morcmsportlet_custDt_corp", "07/05/2018")
05-17-2018 04:33:33 PM - [END]    - End action : Statement - selenium.type("id=_application_portlet_WAR_morcmsportlet_custDt_corp", "07/05/2018")
05-17-2018 04:33:33 PM - [START]  - Start action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_btnAddHQAddress")
05-17-2018 04:33:33 PM - [END]    - End action : Statement - selenium.click("id=_application_portlet_WAR_morcmsportlet_btnAddHQAddress")
05-17-2018 04:33:33 PM - [START]  - Start action : Statement - selenium.selectFrame("index=0")
05-17-2018 04:33:33 PM - [END]    - End action : Statement - selenium.selectFrame("index=0")
05-17-2018 04:33:33 PM - [ERROR]  - Test Cases/New Test Case 1 FAILED because (of) com.thoughtworks.selenium.SeleniumException: no such frame
  (Session info: chrome=66.0.3359.139)
  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86) (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: 'NB7INTERN18M', ip: '176.175.12.39', os.name: 'Windows 7', os.arch: 'x86', 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\vilvamanggkhai\App...}, 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: 66.0.3359.139, webStorageEnabled: true}
Session ID: 6ea4d9fdedc35b6cbe8830fc3aa58d10
05-17-2018 04:33:33 PM - [END]    - End Test Case : Test Cases/New Test Case 1`
这是错误消息:

> `Test Cases/New Test Case 1 FAILED because (of) com.thoughtworks.selenium.SeleniumException: no such frame
  (Session info: chrome=66.0.3359.139)
  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86) (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: 'NB7INTERN18M', ip: '176.175.12.39', os.name: 'Windows 7', os.arch: 'x86', 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\vilvamanggkhai\App...}, 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: 66.0.3359.139, webStorageEnabled: true}
Session ID: 6ea4d9fdedc35b6cbe8830fc3aa58d10

Test Cases/New Test Case 1.run:87`
此错误消息

05-17-2018 04:33:33 PM - [ERROR]  - Test Cases/New Test Case 1 FAILED because (of) com.thoughtworks.selenium.SeleniumException: no such frame
  (Session info: chrome=66.0.3359.139)
  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86) (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'
…意味着ChromeDriver无法找到所需帧并引发硒异常:没有这样的帧

这里有三个问题,如下所示:

selenium.click('id=_application_portlet_WAR_morcmsportlet_btnAddHQAddress')
selenium.selectFrame('index=0')
selenium.click('id=_application_portlet_WAR_morcmsportlet_postalTx')
您已经在元素上调用了
click()
,切换了帧,并在帧内背靠背地调用了
click()
,如下所示:

selenium.click('id=_application_portlet_WAR_morcmsportlet_btnAddHQAddress')
selenium.selectFrame('index=0')
selenium.click('id=_application_portlet_WAR_morcmsportlet_postalTx')
理想情况下,一旦在打开所需框架的元素上单击()以切换到该框架,您需要引导WebDriverWait使该框架可用,然后按如下方式切换到该框架(Python版本):

在这里,您将看到有关的详细讨论

向前看,要再次对框架内的元素调用
click()
,您必须诱导WebDriverwait使该元素可单击,如下所示(Python版本):

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

selenium.click('id=_application_portlet_WAR_morcmsportlet_btnAddHQAddress')
selenium.selectFrame('index=0')
selenium.click('id=_application_portlet_WAR_morcmsportlet_postalTx')
  • 您使用的是chromedriver=2.35
  • 的发行说明明确提到以下内容:
支持Chrome v62-64

  • 您使用的是chrome=66.0
  • 的发行说明明确提到以下内容:
支持Chrome v65-67

  • 您的Selenium客户端版本是2017-11-06T21:07:36.161Z的3.7.1,稍旧一些
因此,Selenium客户端v3.7.1、ChromeDriver v2.35和Chrome浏览器v66.0之间存在明显的不匹配

解决方案
  • 将硒升级到当前水平
  • 将ChromeDriver升级到当前级别
  • 将Chrome版本保持在Chrome v66.x的级别。()
  • 通过IDE清理项目工作区,并仅使用所需的依赖项重建项目
  • 在执行测试套件之前和之后,使用该工具清除所有操作系统杂务
  • 如果您的基本Web客户端版本太旧,请通过卸载它并安装最新的GA和Web客户端发布版本
  • 重新启动系统
  • 执行
    @测试

使用错误堆栈跟踪更新问题,如
“index=0“
和其他相关详细信息,而不是外部链接。它太长,无法作为注释添加。我可以通过“回答”按钮输入吗?不是将此信息添加为注释,而是使用此信息更新主要问题以进行适当的分析,框架是否包含任何属性?比如身份证或类名之类的?是的。但即使我使用它们(这是原始代码的一部分),它仍然不起作用。我使用了selenium。单击(“id=\u应用程序\u portlet\u WAR\u morcmsportlet\u btnAddHQAddress”)对不起。我还是有点迷路。我用的是卡塔隆工作室。我刚刚更新了我的chromedriver。所以你告诉我我需要调用“WebDriverWait(driver,10).until(EC.frame\u to\u be\u available\u和\u switch\u to\u it(By.ID,'ID\u of\u iframe')”,而不添加“selenium.”是吗?因为所有其他行都有。当我尝试更改id并插入您提示的代码行时,仍然会出现此错误。“groovy.lang.MissingMethodException:无方法签名:”这是WebDriverWait的python特定说明。我不知道Katalon Studio如何处理它