Closed aguspe closed 1 month ago
Visit the deploys page to approve it
Name | Link |
---|---|
Latest commit | cf2d31505fb4c6b8a840589a6d39478aff93a48b |
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪ |
🧪 PR contains tests |
🔒 No security concerns identified |
⚡ No key issues to review |
Category | Suggestion | Score |
Performance |
Store the result of repeated element lookups in a variable for reuse___ **To avoid locating the same element multiple times, store the result ofdriver.find_element(name: 'email_input') in a variable and reuse it for both clear and send_keys operations. This reduces the number of WebDriver calls, improving test performance and readability.** [examples/ruby/spec/elements/interaction_spec.rb [15-16]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1815/files#diff-052780b3021b3424286fd0c7da70a500124568d1dbd1a62e38e84e78770af8aaR15-R16) ```diff -driver.find_element(name: 'email_input').clear -driver.find_element(name: 'email_input').send_keys 'admin@localhost.dev' +email_input = driver.find_element(name: 'email_input') +email_input.clear +email_input.send_keys 'admin@localhost.dev' ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 9Why: This suggestion improves performance and readability by reducing the number of WebDriver calls. It is a good practice to store the result of repeated element lookups in a variable. | 9 |
Robustness |
Add error handling for element interaction commands___ **Consider adding error handling for theclick and send_keys operations to manage exceptions that might occur if elements are not found or are not interactable.** [examples/ruby/spec/elements/interaction_spec.rb [11-16]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1815/files#diff-052780b3021b3424286fd0c7da70a500124568d1dbd1a62e38e84e78770af8aaR11-R16) ```diff -driver.find_element(name: 'color_input').click -driver.find_element(name: 'email_input').send_keys 'admin@localhost.dev' +begin + driver.find_element(name: 'color_input').click + email_input = driver.find_element(name: 'email_input') + email_input.clear + email_input.send_keys 'admin@localhost.dev' +rescue Selenium::WebDriver::Error::NoSuchElementError => e + puts "Element not found: #{e}" +end ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 8Why: Adding error handling improves the robustness of the test by managing exceptions that might occur if elements are not found or are not interactable. This is important for reliable test execution. | 8 |
User description
Description
This PR moves the examples for ruby regarding element interactions
Motivation and Context
It's important to make our documentation more maintainable for future contributors to keep the examples up to date
Types of changes
Checklist
PR Type
Documentation, Enhancement
Description
Changes walkthrough 📝
interaction_spec.rb
Add RSpec tests for element interactions in Ruby
examples/ruby/spec/elements/interaction_spec.rb
before
block to navigate to a specific URL before eachtest.
interactions.en.md
Update Ruby interaction examples to use RSpec tests
website_and_docs/content/documentation/webdriver/elements/interactions.en.md
interactions.ja.md
Update Ruby interaction examples to use RSpec tests (Japanese)
website_and_docs/content/documentation/webdriver/elements/interactions.ja.md
interactions.pt-br.md
Update Ruby interaction examples to use RSpec tests (Portuguese)
website_and_docs/content/documentation/webdriver/elements/interactions.pt-br.md
interactions.zh-cn.md
Update Ruby interaction examples to use RSpec tests (Chinese)
website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md