Skip to content

Commit

Permalink
Merge branch 'trunk' into renovate/selenium-webdriver-4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha509 authored Jun 23, 2024
2 parents 16b6ee3 + c3745ec commit 01543c0
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 178 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ruby-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
bundler-cache: true
- name: Install Gems Nightly non-Windows
if: matrix.release == 'nightly' && matrix.os != 'windows-latest'
run:
run:
|
latest_nightly_webdriver=$(./scripts/latest-nightly-version.sh rubygems selenium-webdriver)
cd examples/ruby
Expand All @@ -62,7 +62,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Gems Nightly Windows
if: matrix.release == 'nightly' && matrix.os == 'windows-latest'
run:
run:
|
$latest_nightly_webdriver = ./scripts/latest-nightly-version.ps1 rubygems selenium-webdriver
cd examples/ruby
Expand Down
13 changes: 13 additions & 0 deletions examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,18 @@ public void setPageLoadStrategyNone() {
driver.quit();
}
}

@Test
public void setAcceptInsecureCerts() {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setAcceptInsecureCerts(true);
WebDriver driver = new ChromeDriver(chromeOptions);
try {
// Navigate to Url
driver.get("https://selenium.dev");
} finally {
driver.quit();
}
}
}

6 changes: 4 additions & 2 deletions examples/ruby/spec/browsers/safari_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
describe 'Service' do
let(:directory) { "#{Dir.home}/Library/Logs/com.apple.WebDriver/*" }

it 'enable logs' do
it 'enables logs' do
original_count = Dir[directory].length
service = Selenium::WebDriver::Service.safari

Expand All @@ -31,10 +31,12 @@
}.to raise_error(Selenium::WebDriver::Error::WebDriverError, /Safari Service does not support setting log output/)
end
end
end

RSpec.describe 'Safari Technology Preview', skip: "This test is being skipped as GitHub Actions have no support for Safari Technology Preview" do
it 'sets the technology preview' do
Selenium::WebDriver::Safari.technology_preview!
local_driver = Selenium::WebDriver.for :safari
expect(local_driver.capabilities.browser_name).to eq 'Safari Technology Preview'
end
end
end
60 changes: 58 additions & 2 deletions examples/ruby/spec/elements/locators_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@

require 'spec_helper'

RSpec.describe 'Element Locators' do
let(:driver) { start_session }
RSpec.describe 'Element Locators', skip: 'These are reference following the documentation example' do
it 'finds element by class name' do
driver.find_element(class: 'information')
end

it 'finds element by css selector' do
driver.find_element(css: '#fname')
end

it 'finds element by id' do
driver.find_element(id: 'lname')
end

it 'find element by name' do
driver.find_element(name: 'newsletter')
end

it 'finds element by link text' do
driver.find_element(link_text: 'Selenium Official Page')
end

it 'finds element by partial link text' do
driver.find_element(partial_link_text: 'Official Page')
end

it 'finds element by tag name' do
driver.find_element(tag_name: 'a')
end

it 'finds element by xpath' do
driver.find_element(xpath: "//input[@value='f']")
end

context 'with relative locators' do
it 'finds element above' do
driver.find_element({relative: {tag_name: 'input', above: {id: 'password'}}})
end

it 'finds element below' do
driver.find_element({relative: {tag_name: 'input', below: {id: 'email'}}})
end

it 'finds element to the left' do
driver.find_element({relative: {tag_name: 'button', left: {id: 'submit'}}})
end

it 'finds element to the right' do
driver.find_element({relative: {tag_name: 'button', right: {id: 'cancel'}}})
end

it 'finds near element' do
driver.find_element({relative: {tag_name: 'input', near: {id: 'lbl-email'}}})
end

it 'chains relative locators' do
driver.find_element({relative: {tag_name: 'button', below: {id: 'email'}, right: {id: 'cancel'}}})
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ available in Selenium.
var driver = new ChromeDriver();
driver.FindElement(By.ClassName("information"));
{{< /tab >}}
{{< tab header="Ruby" >}}
driver = Selenium::WebDriver.for :chrome
driver.find_element(class: 'information')
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L7" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let driver = await new Builder().forBrowser('chrome').build();
Expand Down Expand Up @@ -123,10 +122,9 @@ textbox, using css.
var driver = new ChromeDriver();
driver.FindElement(By.CssSelector("#fname"));
{{< /tab >}}
{{< tab header="Ruby" >}}
driver = Selenium::WebDriver.for :chrome
driver.find_element(css: '#fname')
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L11" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let driver = await new Builder().forBrowser('chrome').build();
const loc = await driver.findElement(By.css('#fname'));
Expand Down Expand Up @@ -156,10 +154,9 @@ We will identify the Last Name field using it.
var driver = new ChromeDriver();
driver.FindElement(By.Id("lname"));
{{< /tab >}}
{{< tab header="Ruby" >}}
driver = Selenium::WebDriver.for :chrome
driver.find_element(id: 'lname')
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L15" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let driver = await new Builder().forBrowser('chrome').build();
const loc = await driver.findElement(By.id('lname'));
Expand Down Expand Up @@ -190,10 +187,9 @@ We will identify the Newsletter checkbox using it.
var driver = new ChromeDriver();
driver.FindElement(By.Name("newsletter"));
{{< /tab >}}
{{< tab header="Ruby" >}}
driver = Selenium::WebDriver.for :chrome
driver.find_element(name: 'newsletter')
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L19" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let driver = await new Builder().forBrowser('chrome').build();
const loc = await driver.findElement(By.name('newsletter'));
Expand Down Expand Up @@ -222,10 +218,9 @@ In the HTML snippet shared, we have a link available, let's see how will we loca
var driver = new ChromeDriver();
driver.FindElement(By.LinkText("Selenium Official Page"));
{{< /tab >}}
{{< tab header="Ruby" >}}
driver = Selenium::WebDriver.for :chrome
driver.find_element(link_text: 'Selenium Official Page')
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L23" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let driver = await new Builder().forBrowser('chrome').build();
const loc = await driver.findElement(By.linkText('Selenium Official Page'));
Expand Down Expand Up @@ -255,10 +250,9 @@ In the HTML snippet shared, we have a link available, lets see how will we locat
var driver = new ChromeDriver();
driver.FindElement(By.PartialLinkText("Official Page"));
{{< /tab >}}
{{< tab header="Ruby" >}}
driver = Selenium::WebDriver.for :chrome
driver.find_element(partial_link_text: 'Official Page')
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L27" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let driver = await new Builder().forBrowser('chrome').build();
const loc = await driver.findElement(By.partialLinkText('Official Page'));
Expand Down Expand Up @@ -286,10 +280,9 @@ From the above HTML snippet shared, lets identify the link, using its html tag "
var driver = new ChromeDriver();
driver.FindElement(By.TagName("a"));
{{< /tab >}}
{{< tab header="Ruby" >}}
driver = Selenium::WebDriver.for :chrome
driver.find_element(tag_name: 'a')
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L31" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let driver = await new Builder().forBrowser('chrome').build();
const loc = await driver.findElement(By.tagName('a'));
Expand Down Expand Up @@ -323,10 +316,9 @@ first name text box. Let us create locator for female radio button using xpath.
var driver = new ChromeDriver();
driver.FindElement(By.Xpath("//input[@value='f']"));
{{< /tab >}}
{{< tab header="Ruby" >}}
driver = Selenium::WebDriver.for :chrome
driver.find_element(xpath: '//input[@value='f']')
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L35" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let driver = await new Builder().forBrowser('chrome').build();
const loc = await driver.findElement(By.xpath('//input[@value='f']'));
Expand Down Expand Up @@ -377,8 +369,8 @@ email_locator = locate_with(By.TAG_NAME, "input").above({By.ID: "password"})
{{< tab header="CSharp" >}}
var emailLocator = RelativeBy.WithLocator(By.TagName("input")).Above(By.Id("password"));
{{< /tab >}}
{{< tab header="Ruby" >}}
email_locator = {relative: {tag_name: 'input', above: {id: 'password'}}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L40" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let emailLocator = locateWith(By.tagName('input')).above(By.id('password'));
Expand All @@ -404,8 +396,8 @@ password_locator = locate_with(By.TAG_NAME, "input").below({By.ID: "email"})
{{< tab header="CSharp" >}}
var passwordLocator = RelativeBy.WithLocator(By.TagName("input")).Below(By.Id("email"));
{{< /tab >}}
{{< tab header="Ruby" >}}
password_locator = {relative: {tag_name: 'input', below: {id: 'email'}}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L44" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let passwordLocator = locateWith(By.tagName('input')).below(By.id('email'));
Expand All @@ -431,8 +423,8 @@ cancel_locator = locate_with(By.TAG_NAME, "button").to_left_of({By.ID: "submit"}
{{< tab header="CSharp" >}}
var cancelLocator = RelativeBy.WithLocator(By.tagName("button")).LeftOf(By.Id("submit"));
{{< /tab >}}
{{< tab header="Ruby" >}}
cancel_locator = {relative: {tag_name: 'button', left: {id: 'submit'}}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L48" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let cancelLocator = locateWith(By.tagName('button')).toLeftOf(By.id('submit'));
Expand All @@ -458,8 +450,8 @@ submit_locator = locate_with(By.TAG_NAME, "button").to_right_of({By.ID: "cancel"
{{< tab header="CSharp" >}}
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).RightOf(By.Id("cancel"));
{{< /tab >}}
{{< tab header="Ruby" >}}
submit_locator = {relative: {tag_name: 'button', right: {id: 'cancel'}}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L52" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let submitLocator = locateWith(By.tagName('button')).toRightOf(By.id('cancel'));
Expand Down Expand Up @@ -487,8 +479,8 @@ email_locator = locate_with(By.TAG_NAME, "input").near({By.ID: "lbl-email"})
{{< tab header="CSharp" >}}
var emailLocator = RelativeBy.WithLocator(By.tagName("input")).Near(By.Id("lbl-email"));
{{< /tab >}}
{{< tab header="Ruby" >}}
email_locator = {relative: {tag_name: 'input', near: {id: 'lbl-email'}}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L56" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let emailLocator = locateWith(By.tagName('input')).near(By.id('lbl-email'));
Expand All @@ -513,8 +505,8 @@ submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_r
{{< tab header="CSharp" >}}
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel"));
{{< /tab >}}
{{< tab header="Ruby" >}}
submit_locator = {relative: {tag_name: 'button', below: {id: 'email'}, right: {id: 'cancel'}}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L60" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let submitLocator = locateWith(By.tagName('button')).below(By.id('email')).toRightOf(By.id('cancel'));
Expand Down
Loading

0 comments on commit 01543c0

Please sign in to comment.