SFDO-Tooling / CumulusCI

Python framework for building portable automation for Salesforce projects
http://cumulusci.readthedocs.io
BSD 3-Clause "New" or "Revised" License
363 stars 244 forks source link

Last week this test worked, now I get a javascriptexception message. #987

Open EthanKing96 opened 5 years ago

EthanKing96 commented 5 years ago

Error: JavascriptException: Message: javascript error: Cannot read property 'defaultView' of undefined (Session info: chrome=72.0.3626.109) (Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.0 x86_64)

The error is occurring after I login, and start Create New Contact process. Robot can't find the Contact tab and sends back this error.

I think the issue is that when robot is running in chrome and you inspect the inspect element brings you to the top of the body element. Then you have to inspect again and it will actually bring you to the element you selected. Is there a work around for that? This didn't happen before the Spring 19' update on regular tabbed objects, although it did happen on object buttons such as Accounts > New Button. To work around that I did Wait For Aura after opening an object page to select the New button. But that does not seem to work in this scenario.

For some reason I cant attach a robot file so I will paste the code below. Please help!

*** Settings ***
Library    SeleniumLibrary
Library    cumulusci.robotframework.CumulusCI
Library    cumulusci.robotframework.Salesforce
variables    variables.py

*** Test Cases ***
Salesforce Contact Creation/Deletion
    TestSetup
    Login
    Verify Login
    Create New Contact
    Enter Name
    Enter Account
    Save Contact
    Delete Contact
    Teardown

*** Keywords ***
TestSetup 
    Open Browser    https://login.salesforce.com/    chrome

Verify Login
    Wait Until Page Contains    Home    timeout=20
Teardown
    Close Browser
Save Contact
    Click Modal Button    Save
Delete Contact
    Wait For Aura
    Click Object Button    Delete
    Click Modal Button    Delete
Enter Account
    Click Element    class:uiInput--lookup
    Input Text    class:uiInput--lookup    ${ACCOUNT}
    Click Element    class:slds-lookup__result-text
Enter Name
    Wait Until Modal Is Open
    Input Text    class:firstName    ${F_NAME}
    Input Text    class:lastName    ${L_NAME}
Login
    Input Text    id:username    ${USERNAME}
    Input Text    id:password    ${PASSWORD}
    Click Element     Login
Create New Contact
    Click Link    Contacts
    Wait For Aura
    Click Object Button    New
davisagli commented 5 years ago

We've also seen this in a different part of the UI since the Spring 19 release, and are still looking for a good workaround. It appears to be a general issue with chromedriver when interacting with elements inside a shadow DOM: https://stackoverflow.com/questions/49906451/web-driver-click-on-element-within-shadowdom-is-returning-error-messageunk

EthanKing96 commented 5 years ago

Its almost like there needs to be a way to double click on everything without breaking the test. If you inspect on say the Account object the first time you get brought to the top of the body element, then on second inspect you get brought to the actual element. Could that be a possible fix in the meantime? I have to create automated salesforce tests for my position, so this breaking is making me scramble a bit.

Any sort of help would be hugely beneficial.

Thank you!

EthanKing96 commented 5 years ago

@davisagli I figured out a work-around. Use firefox with geckodriver. Everything works as intended now. Thank you!

Szandor72 commented 5 years ago

While Firefox is currently a life saver for interacting with lightning components that have a shadow DOM, I would like to see an approach for us to also use Chrome without hassle.

I have tried to read up on the problem in the repositories involved and found that robot points to selenium and selenium points to WC3 and nothing much has happened in about a year.

Was wondering if CCI could implement a python class that would solve the problem at hand.

davisagli commented 5 years ago

For the specific case of navigating to a tab, you can use the Select App Launcher Tab keyword from the Salesforce library. (It uses the app launcher, which has the benefit of working even if that tab isn't shown in the current app.)

I'm not sure at this point what the right general solution is for interacting with shadow DOM elements -- we haven't spent much time on this, because it's not something that Salesforce.org product teams have been running into much, somewhat surprisingly.

Szandor72 commented 5 years ago

That is indeed interesting. Any custom component utilizing lightning-input (or lightning:input for that matter) is not accessible anymore for us with robot/selenium/webdriver/chrome.

Nominally, that was part of the winter release - but the tests started failing long after the tests succeeded in the first winter20 orgs. I suppose they pushed that a little later.

My knowledge is not sufficient to implement what the Release Note suggest ( https://www.seleniumeasy.com/selenium-tutorials/accessing-shadow-dom-elements-with-webdriver )

If I can be pointed in the right direction, I will further investigate.

On Tue, 22 Oct 2019 at 16:12, David Glick notifications@github.com wrote:

For the specific case of navigating to a tab, you can use the Select App Launcher Tab keyword from the Salesforce library. (It uses the app launcher, which has the benefit of working even if that tab isn't shown in the current app.)

I'm not sure at this point what the right general solution is for interacting with shadow DOM elements -- we haven't spent much time on this, because it's not something that Salesforce.org product teams have been running into much, somewhat surprisingly.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SFDO-Tooling/CumulusCI/issues/987?email_source=notifications&email_token=AEAGS6S2WMUKMHLTV5GVOUDQP4C6PA5CNFSM4GXPN7B2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB54PMI#issuecomment-544982961, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEAGS6RGCER6CYBEYGNB5PDQP4C6PANCNFSM4GXPN7BQ .

Szandor72 commented 4 years ago

We're still happy with firefox+robot - just curious if there's any change since last we talked?

davisagli commented 4 years ago

@boakley Am I right in thinking we are doing a click using javascript instead of the selenium click command to work around shadow DOM navigation issues in some cases? If so could you point @Szandor72 to an example?

davidmreed commented 2 years ago

@Szandor72 Is this issue still impacting you?