Skip to content

[rb] Move information examples #1826

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

Merged
merged 4 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions examples/ruby/spec/elements/information_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,48 @@

RSpec.describe 'Element Information' do
let(:driver) { start_session }
let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }

before { driver.get(url) }

it 'checks if an element is displayed' do
displayed_value = driver.find_element(name: 'email_input').displayed?
expect(displayed_value).to be_truthy
end

it 'checks if an element is enabled' do
enabled_value = driver.find_element(name: 'email_input').enabled?
expect(enabled_value).to be_truthy
end

it 'checks if an element is selected' do
selected_value = driver.find_element(name: 'email_input').selected?
expect(selected_value).to be_falsey
end

it 'gets the tag name of an element' do
tag_name = driver.find_element(name: 'email_input').tag_name
expect(tag_name).to eq('input')
end

it 'gets the size and position of an element' do
size = driver.find_element(name: 'email_input').size
expect(size.width).to eq(147)
expect(size.height).to eq(22)
end

it 'gets the css value of an element' do
css_value = driver.find_element(name: 'email_input').css_value('background-color')
expect(css_value).to eq('rgba(255, 255, 255, 1)')
end

it 'gets the text of an element' do
text = driver.find_element(xpath: '//h1').text
expect(text).to eq('Testing Inputs')
end

it 'gets the attribute value of an element' do
attribute_value = driver.find_element(name: 'number_input').attribute('value')
expect(attribute_value).to eq '42'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ driver.Url = "https://www.selenium.dev/selenium/web/inputs.html";
//Get boolean value for is element display
Boolean is_email_visible = driver.FindElement(By.Name("email_input")).Displayed;
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html");

#fetch display status
val = driver.find_element(name: 'email_input').displayed?
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L12">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L16-L17">}}
Expand Down Expand Up @@ -93,13 +89,9 @@ IWebElement element = driver.FindElement(By.Name("button_input"));
// Prints true if element is enabled else returns false
System.Console.WriteLine(element.Enabled);
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'

# Returns true if element is enabled else returns false
ele = driver.find_element(name: 'button_input').enabled?
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L17">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L23-L24">}}
{{< /tab >}}
Expand Down Expand Up @@ -139,13 +131,9 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
// Returns true if element ins checked else returns false
bool value = driver.FindElement(By.Name("checkbox_input")).Selected;
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'

# Returns true if element is checked else returns false
ele = driver.find_element(name: "checkbox_input").selected?
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L22">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L30-L31">}}
{{< /tab >}}
Expand Down Expand Up @@ -181,13 +169,9 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
// Returns TagName of the element
string attr = driver.FindElement(By.Name("email_input")).TagName;
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'

# Returns TagName of the element
attr = driver.find_element(name: "email_input").tag_name
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L27">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L37-L38">}}
{{< /tab >}}
Expand Down Expand Up @@ -232,13 +216,9 @@ System.Console.WriteLine(res.Location);
// Returns height, width
System.Console.WriteLine(res.Size);
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'

# Returns height, width, x and y coordinates referenced element
res = driver.find_element(name: "range_input").rect
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L32">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L45">}}
{{< /tab >}}
Expand Down Expand Up @@ -281,14 +261,8 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/colorPage.html"
String cssValue = driver.FindElement(By.Id("namedColor")).GetCssValue("background-color");

{{< /tab >}}
{{< tab header="Ruby" >}}

# Navigate to Url
driver.get 'https://www.selenium.dev/selenium/web/colorPage.html'

# Retrieves the computed style property 'color' of linktext
cssValue = driver.find_element(:id, 'namedColor').css_value('background-color')

{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L38">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L76-L78">}}
Expand Down Expand Up @@ -326,13 +300,9 @@ driver.Url="https://www.selenium.dev/selenium/web/linked_image.html";
// Retrieves the text of the element
String text = driver.FindElement(By.Id("justanotherlink")).Text;
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/linked_image.html'

# Retrieves the text of the element
text = driver.find_element(:id, 'justanotherlink').text
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L43">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L84-L86">}}
{{< /tab >}}
Expand Down Expand Up @@ -377,16 +347,9 @@ IWebElement emailTxt = driver.FindElement(By.Name(("email_input")));
//fetch the value property associated with the textbox
String valueInfo = eleSelLink.GetAttribute("value");
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html");

#identify the email text box
email_element=driver.find_element(name: 'email_input')

#fetch the value property associated with the textbox
emailVal = email_element.attribute("value");
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L48">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L55-L59">}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ driver.Url = "https://www.selenium.dev/selenium/web/inputs.html";
//Get boolean value for is element display
Boolean is_email_visible = driver.FindElement(By.Name("email_input")).Displayed;
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html");

#fetch display status
val = driver.find_element(name: 'email_input').displayed?
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L12">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L16-L17">}}
Expand Down Expand Up @@ -90,13 +86,9 @@ IWebElement element = driver.FindElement(By.Name("button_input"));
// Prints true if element is enabled else returns false
System.Console.WriteLine(element.Enabled);
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'

# Returns true if element is enabled else returns false
ele = driver.find_element(name: 'button_input').enabled?
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L17">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L23-L24">}}
{{< /tab >}}
Expand Down Expand Up @@ -134,13 +126,9 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
// Returns true if element ins checked else returns false
bool value = driver.FindElement(By.Name("checkbox_input")).Selected;
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'

# Returns true if element is checked else returns false
ele = driver.find_element(name: "checkbox_input").selected?
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L22">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L30-L31">}}
{{< /tab >}}
Expand Down Expand Up @@ -176,13 +164,9 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
// Returns TagName of the element
string attr = driver.FindElement(By.Name("email_input")).TagName;
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'

# Returns TagName of the element
attr = driver.find_element(name: "email_input").tag_name
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L27">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L37-L38">}}
{{< /tab >}}
Expand Down Expand Up @@ -227,13 +211,9 @@ System.Console.WriteLine(res.Location);
// Returns height, width
System.Console.WriteLine(res.Size);
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'

# Returns height, width, x and y coordinates referenced element
res = driver.find_element(name: "range_input").rect
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L32">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L45">}}
{{< /tab >}}
Expand Down Expand Up @@ -275,14 +255,8 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/colorPage.html"
String cssValue = driver.FindElement(By.Id("namedColor")).GetCssValue("background-color");

{{< /tab >}}
{{< tab header="Ruby" >}}

# Navigate to Url
driver.get 'https://www.selenium.dev/selenium/web/colorPage.html'

# Retrieves the computed style property 'color' of linktext
cssValue = driver.find_element(:id, 'namedColor').css_value('background-color')

{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L38">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L76-L78">}}
Expand Down Expand Up @@ -321,13 +295,9 @@ driver.Url="https://www.selenium.dev/selenium/web/linked_image.html";
// Retrieves the text of the element
String text = driver.FindElement(By.Id("justanotherlink")).Text;
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to url
driver.get 'https://www.selenium.dev/selenium/web/linked_image.html'

# Retrieves the text of the element
text = driver.find_element(:id, 'justanotherlink').text
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L43">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L84-L86">}}
{{< /tab >}}
Expand Down Expand Up @@ -370,16 +340,9 @@ IWebElement emailTxt = driver.FindElement(By.Name(("email_input")));
//fetch the value property associated with the textbox
String valueInfo = eleSelLink.GetAttribute("value");
{{< /tab >}}
{{< tab header="Ruby" >}}
# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html");

#identify the email text box
email_element=driver.find_element(name: 'email_input')

#fetch the value property associated with the textbox
emailVal = email_element.attribute("value");
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L48">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L55-L59">}}
{{< /tab >}}
Expand Down
Loading
Loading