diff --git a/examples/ruby/spec/elements/locators_spec.rb b/examples/ruby/spec/elements/locators_spec.rb index 99e1544d1a60..1b8448ad5933 100644 --- a/examples/ruby/spec/elements/locators_spec.rb +++ b/examples/ruby/spec/elements/locators_spec.rb @@ -2,62 +2,100 @@ require 'spec_helper' -RSpec.describe 'Element Locators', skip: 'These are reference following the documentation example' do +RSpec.describe 'Element Locators' do + let(:driver) { start_session } + let(:url) { 'https://www.selenium.dev/selenium/web/locators_tests/locators.html' } + + before { driver.get(url) } + it 'finds element by class name' do - driver.find_element(class: 'information') + ele1 = driver.find_element(class: 'information') + expect(ele1).not_to be_nil + expect(ele1.tag_name).to eq('input') end it 'finds element by css selector' do - driver.find_element(css: '#fname') + ele = driver.find_element(css: '#fname') + expect(ele).not_to be_nil + expect(ele.attribute('value')).to eq('Jane') end it 'finds element by id' do - driver.find_element(id: 'lname') + ele2 = driver.find_element(id: 'lname') + expect(ele2).not_to be_nil + expect(ele2.attribute('value')).to eq('Doe') end - it 'find element by name' do - driver.find_element(name: 'newsletter') + it 'finds element by name' do + ele3 = driver.find_element(name: 'newsletter') + expect(ele3).not_to be_nil + expect(ele3.tag_name).to eq('input') end it 'finds element by link text' do - driver.find_element(link_text: 'Selenium Official Page') + ele = driver.find_element(link_text: 'Selenium Official Page') + expect(ele).not_to be_nil + expect(ele.attribute('href')).to eq('https://www.selenium.dev/') end it 'finds element by partial link text' do - driver.find_element(partial_link_text: 'Official Page') + ele = driver.find_element(partial_link_text: 'Official Page') + expect(ele).not_to be_nil + expect(ele.attribute('href')).to eq('https://www.selenium.dev/') end it 'finds element by tag name' do - driver.find_element(tag_name: 'a') + ele = driver.find_element(tag_name: 'a') + expect(ele).not_to be_nil + expect(ele.attribute('href')).to eq('https://www.selenium.dev/') end it 'finds element by xpath' do - driver.find_element(xpath: "//input[@value='f']") + ele = driver.find_element(xpath: "//input[@value='f']") + expect(ele).not_to be_nil + expect(ele.attribute('type')).to eq('radio') end context 'with relative locators' do + let(:url) do + form = <<~HTML +
+ HTML + "data:text/html,#{form}" + end + it 'finds element above' do - driver.find_element({relative: {tag_name: 'input', above: {id: 'password'}}}) + ele = driver.find_element(relative: {tag_name: 'input', above: {id: 'password'}}) + expect(ele).not_to be_nil end it 'finds element below' do - driver.find_element({relative: {tag_name: 'input', below: {id: 'email'}}}) + ele = driver.find_element(relative: {tag_name: 'input', below: {id: 'email'}}) + expect(ele).not_to be_nil end it 'finds element to the left' do - driver.find_element({relative: {tag_name: 'button', left: {id: 'submit'}}}) + ele = driver.find_element(relative: {tag_name: 'button', left: {id: 'submit'}}) + expect(ele).not_to be_nil end it 'finds element to the right' do - driver.find_element({relative: {tag_name: 'button', right: {id: 'cancel'}}}) + ele = driver.find_element(relative: {tag_name: 'button', right: {id: 'cancel'}}) + expect(ele).not_to be_nil end it 'finds near element' do - driver.find_element({relative: {tag_name: 'input', near: {id: 'lbl-email'}}}) + ele = driver.find_element(relative: {tag_name: 'input', near: {id: 'lbl-email'}}) + expect(ele).not_to be_nil end it 'chains relative locators' do - driver.find_element({relative: {tag_name: 'button', below: {id: 'email'}, right: {id: 'cancel'}}}) + ele = driver.find_element(relative: {tag_name: 'button', below: {id: 'email'}, right: {id: 'cancel'}}) + expect(ele).not_to be_nil end end end diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.en.md b/website_and_docs/content/documentation/webdriver/elements/locators.en.md index a4b25ce9f2a7..a5af2d481153 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.en.md @@ -85,7 +85,7 @@ In Selenium, we can locate these specific elements using the class name locator. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L20-L21" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L7" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L12" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/elements/locators.spec.js#L6-L8" >}} @@ -115,7 +115,7 @@ textbox, using css. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L23-L24" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L11" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L18" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/elements/locators.spec.js#L20-L22" >}} @@ -143,7 +143,7 @@ We will identify the Last Name field using it. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L26-L27" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L15" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L24" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/elements/locators.spec.js#L35-L37" >}} @@ -172,7 +172,7 @@ We will identify the Newsletter checkbox using it. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L29-L30" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L19" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L30" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/elements/locators.spec.js#L50-L52" >}} @@ -199,7 +199,7 @@ In the HTML snippet shared, we have a link available, let's see how will we loca {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L32-L33" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L23" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L36" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/elements/locators.spec.js#L67-L69" >}} @@ -225,7 +225,7 @@ based on a portion of their visible text, rather than needing the entire string. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L35-L36" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L27" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L42" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/elements/locators.spec.js#L80-L82" >}} @@ -251,7 +251,7 @@ From the above HTML snippet shared, lets identify the link, using its html tag " {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L38-L39" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L31" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L48" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/elements/locators.spec.js#L93-L95" >}} @@ -281,7 +281,7 @@ Let's see an example to create the XPath locator for the female radio button. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L41-L42" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L35" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L54" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/elements/locators.spec.js#L106-L108" >}} @@ -424,7 +424,7 @@ email_locator = locate_with(By.TAG_NAME, "input").above({By.ID: "password"}) var emailLocator = RelativeBy.WithLocator(By.TagName("input")).Above(By.Id("password")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L40" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L72" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let emailLocator = locateWith(By.tagName('input')).above(By.id('password')); @@ -451,7 +451,7 @@ password_locator = locate_with(By.TAG_NAME, "input").below({By.ID: "email"}) var passwordLocator = RelativeBy.WithLocator(By.TagName("input")).Below(By.Id("email")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L44" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L77" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let passwordLocator = locateWith(By.tagName('input')).below(By.id('email')); @@ -478,7 +478,7 @@ cancel_locator = locate_with(By.TAG_NAME, "button").to_left_of({By.ID: "submit"} var cancelLocator = RelativeBy.WithLocator(By.tagName("button")).LeftOf(By.Id("submit")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L48" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L82" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let cancelLocator = locateWith(By.tagName('button')).toLeftOf(By.id('submit')); @@ -505,7 +505,7 @@ submit_locator = locate_with(By.TAG_NAME, "button").to_right_of({By.ID: "cancel" var submitLocator = RelativeBy.WithLocator(By.tagName("button")).RightOf(By.Id("cancel")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L52" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L87" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let submitLocator = locateWith(By.tagName('button')).toRightOf(By.id('cancel')); @@ -534,7 +534,7 @@ email_locator = locate_with(By.TAG_NAME, "input").near({By.ID: "lbl-email"}) var emailLocator = RelativeBy.WithLocator(By.tagName("input")).Near(By.Id("lbl-email")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L56" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L92" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let emailLocator = locateWith(By.tagName('input')).near(By.id('lbl-email')); @@ -560,7 +560,7 @@ submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_r var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L60" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L97" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let submitLocator = locateWith(By.tagName('button')).below(By.id('email')).toRightOf(By.id('cancel')); diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md index 23c3a9739602..1e7bd467a76c 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md @@ -83,7 +83,7 @@ In Selenium, we can locate these specific elements using the class name locator. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L20-L21" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L7" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L12" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -113,7 +113,7 @@ textbox, using css. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L23-L24" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L11" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L18" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -141,7 +141,7 @@ We will identify the Last Name field using it. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L26-L27" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L15" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L24" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -170,7 +170,7 @@ We will identify the Newsletter checkbox using it. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L29-L30" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L19" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L30" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -197,7 +197,7 @@ In the HTML snippet shared, we have a link available, lets see how will we locat {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L32-L33" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L23" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L36" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -223,7 +223,7 @@ based on a portion of their visible text, rather than needing the entire string. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L35-L36" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L27" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L42" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -249,7 +249,7 @@ From the above HTML snippet shared, lets identify the link, using its html tag " {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L38-L39" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L31" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L48" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -279,7 +279,7 @@ Let's see an example to create the XPath locator for the female radio button. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L41-L42" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L35" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L54" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -423,7 +423,7 @@ email_locator = locate_with(By.TAG_NAME, "input").above({By.ID: "password"}) var emailLocator = RelativeBy.WithLocator(By.TagName("input")).Above(By.Id("password")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L40" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L72" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let emailLocator = locateWith(By.tagName('input')).above(By.id('password')); @@ -449,7 +449,7 @@ password_locator = locate_with(By.TAG_NAME, "input").below({By.ID: "email"}) var passwordLocator = RelativeBy.WithLocator(By.TagName("input")).Below(By.Id("email")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L44" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L77" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let passwordLocator = locateWith(By.tagName('input')).below(By.id('email')); @@ -475,7 +475,7 @@ cancel_locator = locate_with(By.TAG_NAME, "button").to_left_of({By.ID: "submit"} var cancelLocator = RelativeBy.WithLocator(By.tagName("button")).LeftOf(By.Id("submit")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L48" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rbL#82" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let cancelLocator = locateWith(By.tagName('button')).toLeftOf(By.id('submit')); @@ -501,7 +501,7 @@ submit_locator = locate_with(By.TAG_NAME, "button").to_right_of({By.ID: "cancel" var submitLocator = RelativeBy.WithLocator(By.tagName("button")).RightOf(By.Id("cancel")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L52" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L87" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let submitLocator = locateWith(By.tagName('button')).toRightOf(By.id('cancel')); @@ -529,7 +529,7 @@ email_locator = locate_with(By.TAG_NAME, "input").near({By.ID: "lbl-email"}) var emailLocator = RelativeBy.WithLocator(By.tagName("input")).Near(By.Id("lbl-email")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L56" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L92" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let emailLocator = locateWith(By.tagName('input')).near(By.id('lbl-email')); @@ -554,7 +554,7 @@ submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_r var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L60" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L97" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let submitLocator = locateWith(By.tagName('button')).below(By.id('email')).toRightOf(By.id('cancel')); diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md b/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md index 938657a01042..e3b2e63457c7 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md @@ -86,7 +86,7 @@ In Selenium, we can locate these specific elements using the class name locator. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L20-L21" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L7" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L12" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -116,7 +116,7 @@ textbox, using css. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L23-L24" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L11" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L18" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -144,7 +144,7 @@ We will identify the Last Name field using it. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L26-L27" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L15" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L24" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -173,7 +173,7 @@ We will identify the Newsletter checkbox using it. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L29-L30" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L19" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L30" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -200,7 +200,7 @@ In the HTML snippet shared, we have a link available, lets see how will we locat {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L32-L33" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L23" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L36" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -226,7 +226,7 @@ based on a portion of their visible text, rather than needing the entire string. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L35-L36" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L27" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L42" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -252,7 +252,7 @@ From the above HTML snippet shared, lets identify the link, using its html tag " {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L38-L39" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L31" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L48" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -282,7 +282,7 @@ Let's see an example to create the XPath locator for the female radio button. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L41-L42" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L35" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L54" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -426,7 +426,7 @@ email_locator = locate_with(By.TAG_NAME, "input").above({By.ID: "password"}) var emailLocator = RelativeBy.WithLocator(By.TagName("input")).Above(By.Id("password")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L40" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L72" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let emailLocator = locateWith(By.tagName('input')).above(By.id('password')); @@ -452,7 +452,7 @@ password_locator = locate_with(By.TAG_NAME, "input").below({By.ID: "email"}) var passwordLocator = RelativeBy.WithLocator(By.TagName("input")).Below(By.Id("email")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L44" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L77" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let passwordLocator = locateWith(By.tagName('input')).below(By.id('email')); @@ -478,7 +478,7 @@ cancel_locator = locate_with(By.TAG_NAME, "button").to_left_of({By.ID: "submit"} var cancelLocator = RelativeBy.WithLocator(By.tagName("button")).LeftOf(By.Id("submit")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L48" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L82" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let cancelLocator = locateWith(By.tagName('button')).toLeftOf(By.id('submit')); @@ -504,7 +504,7 @@ submit_locator = locate_with(By.TAG_NAME, "button").to_right_of({By.ID: "cancel" var submitLocator = RelativeBy.WithLocator(By.tagName("button")).RightOf(By.Id("cancel")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L52" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L87" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let submitLocator = locateWith(By.tagName('button')).toRightOf(By.id('cancel')); @@ -532,7 +532,7 @@ email_locator = locate_with(By.TAG_NAME, "input").near({By.ID: "lbl-email"}) var emailLocator = RelativeBy.WithLocator(By.tagName("input")).Near(By.Id("lbl-email")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L56" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L92" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let emailLocator = locateWith(By.tagName('input')).near(By.id('lbl-email')); @@ -557,7 +557,7 @@ submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_r var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L60" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L97" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let submitLocator = locateWith(By.tagName('button')).below(By.id('email')).toRightOf(By.id('cancel')); diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md b/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md index 7f82676ad8dc..c08a6f4f6d75 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md @@ -86,7 +86,7 @@ In Selenium, we can locate these specific elements using the class name locator. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L20-L21" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L7" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L12" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -116,7 +116,7 @@ textbox, using css. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L23-L24" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L11" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L18" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -144,7 +144,7 @@ We will identify the Last Name field using it. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L26-L27" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L15" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L24" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -173,7 +173,7 @@ We will identify the Newsletter checkbox using it. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L29-L30" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L19" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L30" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -200,7 +200,7 @@ In the HTML snippet shared, we have a link available, lets see how will we locat {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L32-L33" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L23" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L36" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -226,7 +226,7 @@ based on a portion of their visible text, rather than needing the entire string. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L35-L36" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L27" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L42" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -252,7 +252,7 @@ From the above HTML snippet shared, lets identify the link, using its html tag " {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L38-L39" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L31" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L48" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -283,7 +283,7 @@ Let's see an example to create the XPath locator for the female radio button. {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Elements/LocatorsTest.cs#L41-L42" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L35" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L54" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let driver = await new Builder().forBrowser('chrome').build(); @@ -427,7 +427,7 @@ email_locator = locate_with(By.TAG_NAME, "input").above({By.ID: "password"}) var emailLocator = RelativeBy.WithLocator(By.TagName("input")).Above(By.Id("password")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L40" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L72" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let emailLocator = locateWith(By.tagName('input')).above(By.id('password')); @@ -453,7 +453,7 @@ password_locator = locate_with(By.TAG_NAME, "input").below({By.ID: "email"}) var passwordLocator = RelativeBy.WithLocator(By.TagName("input")).Below(By.Id("email")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L44" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L77" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let passwordLocator = locateWith(By.tagName('input')).below(By.id('email')); @@ -479,7 +479,7 @@ cancel_locator = locate_with(By.TAG_NAME, "button").to_left_of({By.ID: "submit"} var cancelLocator = RelativeBy.WithLocator(By.tagName("button")).LeftOf(By.Id("submit")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L48" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L82" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let cancelLocator = locateWith(By.tagName('button')).toLeftOf(By.id('submit')); @@ -505,7 +505,7 @@ submit_locator = locate_with(By.TAG_NAME, "button").to_right_of({By.ID: "cancel" var submitLocator = RelativeBy.WithLocator(By.tagName("button")).RightOf(By.Id("cancel")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L52" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L87" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let submitLocator = locateWith(By.tagName('button')).toRightOf(By.id('cancel')); @@ -533,7 +533,7 @@ email_locator = locate_with(By.TAG_NAME, "input").near({By.ID: "lbl-email"}) var emailLocator = RelativeBy.WithLocator(By.tagName("input")).Near(By.Id("lbl-email")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L56" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L92" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let emailLocator = locateWith(By.tagName('input')).near(By.id('lbl-email')); @@ -558,7 +558,7 @@ submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_r var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel")); {{< /tab >}} {{< tab header="Ruby" text=true >}} -{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L60" >}} +{{< gh-codeblock path="/examples/ruby/spec/elements/locators_spec.rb#L97" >}} {{< /tab >}} {{< tab header="JavaScript" >}} let submitLocator = locateWith(By.tagName('button')).below(By.id('email')).toRightOf(By.id('cancel'));