提问人:ana_nymous13 提问时间:11/4/2023 更新时间:11/4/2023 访问量:24
机器人框架/Selenium 脚本无法在 Salesforce 页面上执行 Javascript
Robot Framework/Selenium Script Fails to Execute Javascript on Salesforce Page
问:
我正在使用 Robot Framework 和 Selenium 为 Salesforce 应用程序进行自动化测试。我已经编写了一个测试用例,用于登录 Salesforce,导航到 Opportunity 页面,并执行 JavaScript 代码片段以与页面上的元素进行交互。但是,我在执行脚本期间遇到错误。这是我的脚本的简化版本:
*** Settings ***
Library SeleniumLibrary
Library Dialogs
Library Telnet
*** Variables ***
${URL} https://mycompany.lightning.force.com/lightning/page/home
${BROWSER} Chrome
${USERNAME} ****
${PASSWORD} ****
${element} xpath://a[@title='Opportunities']
${chrome_options} add_argument("--incognito")
*** Test Cases ***
Open Salesforce Login Page
${chrome_options} Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${chrome_options} add_argument --incognito
Open Browser ${URL} ${BROWSER} options=${chrome_options}
Title Should Be Login | Salesforce
Wait Until Page Contains Username
Input Text id:username ${USERNAME}
Input Text id:password ${PASSWORD}
Click Button id:Login
Wait Until Page Contains Opportunities
Opportunity Creation
Wait Until Page Contains Element xpath://a[@title='Opportunities'] timeout=10s
Execute Javascript document.querySelector("a[title='Opportunities']").click();
当我运行此脚本时,它在执行 Javascript 步骤失败,并出现以下错误:
Opportunity Creation | FAIL |
JavascriptException: Message: javascript error: Cannot read properties of null (reading 'click')
(Session info: chrome=118.0.5993.118)
Stacktrace:
GetHandleVerifier [0x00007FF646798EF2+54786]
(No symbol) [0x00007FF646705612]
(No symbol) [0x00007FF6465BA64B]
(No symbol) [0x00007FF6465BF116]
(No symbol) [0x00007FF6465C14AA]
(No symbol) [0x00007FF646635394]
(No symbol) [0x00007FF64661BE6A]
(No symbol) [0x00007FF646634D02]
(No symbol) [0x00007FF64661BC43]
(No symbol) [0x00007FF6465F0941]
(No symbol) [0x00007FF6465F1B84]
GetHandleVerifier [0x00007FF646AE7F52+3524194]
GetHandleVerifier [0x00007FF646B3D800+3874576]
GetHandleVerifier [0x00007FF646B35D7F+3843215]
GetHandleVerifier [0x00007FF646835086+694166]
(No symbol) [0x00007FF646710A88]
(No symbol) [0x00007FF64670CA94]
(No symbol) [0x00007FF64670CBC2]
(No symbol) [0x00007FF6466FCC83]
(No symbol) [0x00007FFDC169257D]
RtlUserThreadStart [0x00007FFDC2FEAA78+40]
我已经验证了 XPath 定位器和 JavaScript 代码段,两者似乎都是正确的。我还尝试增加页面加载的超时时间,但错误仍然存在。
我觉得总的来说,我在使用 Salesforce 的测试框架时遇到了问题。 有没有人遇到过类似的问题或对如何解决这个问题有任何建议?提前感谢您的帮助!
答: 暂无答案
评论