Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[atoms] use css locators in dom.js #13430

Merged
merged 1 commit into from
Mar 25, 2024
Merged

[atoms] use css locators in dom.js #13430

merged 1 commit into from
Mar 25, 2024

Conversation

joerg1985
Copy link
Member

Description

Using xpaths will need to transfer the complete wicked-good-xpath, this can easily be replaced by a css locator.

Motivation and Context

This will reduce the size of the isDisplayed.js from ~43kb to ~17kb.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (83656d6) 58.48% compared to head (d0fcd5d) 58.48%.
Report is 1 commits behind head on trunk.

❗ Current head d0fcd5d differs from pull request most recent head ceab5b8. Consider uploading reports for the commit ceab5b8 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #13430   +/-   ##
=======================================
  Coverage   58.48%   58.48%           
=======================================
  Files          86       86           
  Lines        5270     5270           
  Branches      220      220           
=======================================
  Hits         3082     3082           
  Misses       1968     1968           
  Partials      220      220           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@titusfortner titusfortner added this to the 4.19 milestone Feb 25, 2024
@titusfortner
Copy link
Member

@twalpole I know you did some work on a separate isDisplayed atom for Capybara. Did you do something similar here?

@twalpole
Copy link
Contributor

twalpole commented Feb 25, 2024

@titusfortner I just went through all the code and removed all the stuff that was supporting legacy browsers - which took it down to 4.7k - lib/capybara/selenium/atoms/isDisplayed.min.js - unminified 16.1k https://github.com/teamcapybara/capybara/blob/master/lib/capybara/selenium/atoms/src/isDisplayed.js. I did not specifically swap from xpath to css because of the added scoping functionality xpath provides, but it likely did involve getting rid of wicked-good-xpath since every modern browser supports it natively without needing a JS polyfill.

":dom",
":errors",
":json",
":useragent",
":xpath",
"//third_party/js/wgxpath",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do we need to depend on wicked good xpath here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is still needed here for legacy browsers to have XPath locator support.

This PR does only remove the need for wicked good xpath for is-displayed atom.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which legacy browsers require it? IE 11?

@titusfortner
Copy link
Member

We've also discussed moving from closure to Typescript for these.

@joerg1985
Copy link
Member Author

We've also discussed moving from closure to Typescript for these.

Is it possible to run TypeScript in IE 11 and old Android versions?

Copy link
Contributor

codiumai-pr-agent-pro bot commented Mar 21, 2024

CI Failure Feedback

(Checks updated until commit d68c0fb)

Action: JavaScript / Build / Build

Failed stage: Run Bazel [❌]

Failure summary:

The action failed due to errors encountered during the build process of the selenium-webdriver
project. Specifically:

  • A declared output javascript/node/selenium-webdriver/lib/atoms/mutation-listener.js was identified
    as a dangling symbolic link, indicating that the target of the symbolic link does not exist.
  • The genrule //javascript/node/selenium-webdriver/lib/atoms:mutation-listener failed to execute
    because not all outputs were created or were invalid.
  • As a result, the target //javascript/node/selenium-webdriver:selenium-webdriver failed to build,
    leading to the failure of the action.

  • Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    963:  Package 'php-symfony-debug-bundle' is not installed, so not removed
    964:  Package 'php-symfony-dependency-injection' is not installed, so not removed
    965:  Package 'php-symfony-deprecation-contracts' is not installed, so not removed
    966:  Package 'php-symfony-discord-notifier' is not installed, so not removed
    967:  Package 'php-symfony-doctrine-bridge' is not installed, so not removed
    968:  Package 'php-symfony-doctrine-messenger' is not installed, so not removed
    969:  Package 'php-symfony-dom-crawler' is not installed, so not removed
    970:  Package 'php-symfony-dotenv' is not installed, so not removed
    971:  Package 'php-symfony-error-handler' is not installed, so not removed
    ...
    
    1908:  at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:461)
    1909:  at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:414)
    1910:  at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(Unknown Source)
    1911:  at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
    1912:  at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
    1913:  at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
    1914:  at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
    1915:  at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
    1916:  �[31m�[1mERROR: �[0m/home/runner/work/selenium/selenium/javascript/node/selenium-webdriver/lib/atoms/BUILD.bazel:39:8: declared output 'javascript/node/selenium-webdriver/lib/atoms/mutation-listener.js' is a dangling symbolic link
    1917:  �[31m�[1mERROR: �[0m/home/runner/work/selenium/selenium/javascript/node/selenium-webdriver/lib/atoms/BUILD.bazel:39:8: Executing genrule //javascript/node/selenium-webdriver/lib/atoms:mutation-listener failed: not all outputs were created or valid
    1918:  Target //javascript/node/selenium-webdriver:selenium-webdriver failed to build
    1919:  �[32mINFO: �[0mElapsed time: 23.409s, Critical Path: 1.55s
    1920:  �[32mINFO: �[0m189 processes: 1 disk cache hit, 181 internal, 7 linux-sandbox.
    1921:  �[31m�[1mERROR: �[0mBuild did NOT complete successfully
    1922:  �[0m
    1923:  ##[error]Process completed with exit code 1.
    

    ✨ CI feedback usage guide:

    The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
    The tool analyzes the failed checks and provides several feedbacks:

    • Failed stage
    • Failed test name
    • Failure summary
    • Relevant error logs

    In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

    /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
    

    where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

    Configuration options

    • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
    • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
    • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
    • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
    • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

    See more information about the checks tool in the docs.

    @titusfortner
    Copy link
    Member

    @joerg1985

    Is it possible to run TypeScript in IE 11 and old Android versions

    Wouldn't we transpile and minify it the same (ish) way closure does?

    Copy link
    Member

    @diemol diemol left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Thank you, @joerg1985!

    @diemol diemol merged commit af49a5e into trunk Mar 25, 2024
    35 of 38 checks passed
    @diemol diemol deleted the is-displayed branch March 25, 2024 14:37
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    5 participants