Skip to content

Commit 1d9f037

Browse files
authored
[rb] Move documentation examples for general interactions and navigation (#1837)[deploy site]
* Add examples for documentation * Move documentation examples
1 parent 6950080 commit 1d9f037

File tree

10 files changed

+118
-48
lines changed

10 files changed

+118
-48
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'spec_helper'
2+
3+
RSpec.describe 'Browser' do
4+
let(:driver) { start_session }
5+
6+
it 'gets the current title' do
7+
driver.navigate.to 'https://www.selenium.dev/'
8+
current_title = driver.title
9+
expect(current_title).to eq 'Selenium'
10+
end
11+
12+
it 'gets the current url' do
13+
driver.navigate.to 'https://www.selenium.dev/'
14+
current_url = driver.current_url
15+
expect(current_url).to eq 'https://www.selenium.dev/'
16+
end
17+
end
Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
1-
# frozen_string_literal: true
2-
31
require 'spec_helper'
42

5-
RSpec.describe 'Navigation' do
3+
RSpec.describe 'Browser' do
64
let(:driver) { start_session }
5+
6+
it 'navigates to a page' do
7+
driver.navigate.to 'https://www.selenium.dev/'
8+
driver.get 'https://www.selenium.dev/'
9+
expect(driver.current_url).to eq 'https://www.selenium.dev/'
10+
end
11+
12+
it 'navigates back' do
13+
driver.navigate.to 'https://www.selenium.dev/'
14+
driver.navigate.to 'https://www.selenium.dev/selenium/web/inputs.html'
15+
driver.navigate.back
16+
expect(driver.current_url).to eq 'https://www.selenium.dev/'
17+
end
18+
19+
it 'navigates forward' do
20+
driver.navigate.to 'https://www.selenium.dev/'
21+
driver.navigate.to 'https://www.selenium.dev/selenium/web/inputs.html'
22+
driver.navigate.back
23+
driver.navigate.forward
24+
expect(driver.current_url).to eq 'https://www.selenium.dev/selenium/web/inputs.html'
25+
end
26+
27+
it 'refreshes the page' do
28+
driver.navigate.to 'https://www.selenium.dev/'
29+
driver.navigate.refresh
30+
expect(driver.current_url).to eq 'https://www.selenium.dev/'
31+
end
732
end

website_and_docs/content/documentation/webdriver/interactions/_index.en.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ You can read the current page title from the browser:
2323
{{< tab header="Python" text=true >}}
2424
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L7" >}}
2525
{{< /tab >}}
26-
{{< tab header="CSharp" >}}driver.Title;{{< /tab >}}
27-
{{< tab header="Ruby" >}}driver.title{{< /tab >}}
26+
{{< tab header="CSharp" >}}driver.Title;{{< /tab >}}
27+
{{< tab header="Ruby" text=true >}}
28+
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
29+
{{< /tab >}}
2830
{{< tab header="JavaScript" text=true >}}
2931
{{< gh-codeblock path="examples/javascript/test/interactions/interactionsIndex.spec.js#L20" >}}
3032
{{< /tab >}}
31-
{{< tab header="Kotlin" >}}driver.title{{< /tab >}}
33+
{{< tab header="Kotlin" >}}driver.title{{< /tab >}}
3234
{{< /tabpane >}}
3335

3436

@@ -45,7 +47,9 @@ You can read the current URL from the browser's address bar using:
4547
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L10" >}}
4648
{{< /tab >}}
4749
{{< tab header="CSharp" >}}driver.Url;{{< /tab >}}
48-
{{< tab header="Ruby" >}}driver.current_url{{< /tab >}}
50+
{{< tab header="Ruby" text=true >}}
51+
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L14" >}}
52+
{{< /tab >}}
4953
{{< tab header="JavaScript" text=true >}}
5054
{{< gh-codeblock path="examples/javascript/test/interactions/interactionsIndex.spec.js#L24" >}}
5155
{{< /tab >}}

website_and_docs/content/documentation/webdriver/interactions/_index.ja.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ aliases: [
2323
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L7" >}}
2424
{{< /tab >}}
2525
{{< tab header="CSharp" >}}driver.Title;{{< /tab >}}
26-
{{< tab header="Ruby" >}}driver.title{{< /tab >}}
26+
{{< tab header="Ruby" text=true >}}
27+
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
28+
{{< /tab >}}
2729
{{< tab header="JavaScript" text=true >}}
2830
{{< gh-codeblock path="examples/javascript/test/interactions/interactionsIndex.spec.js#L20" >}}
2931
{{< /tab >}}
@@ -43,7 +45,9 @@ aliases: [
4345
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L10" >}}
4446
{{< /tab >}}
4547
{{< tab header="CSharp" >}}driver.Url;{{< /tab >}}
46-
{{< tab header="Ruby" >}}driver.current_url{{< /tab >}}
48+
{{< tab header="Ruby" text=true >}}
49+
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L14" >}}
50+
{{< /tab >}}
4751
{{< tab header="JavaScript" text=true >}}
4852
{{< gh-codeblock path="examples/javascript/test/interactions/interactionsIndex.spec.js#L24" >}}
4953
{{< /tab >}}

website_and_docs/content/documentation/webdriver/interactions/_index.pt-br.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Você pode ler o título da página atual no navegador:
2424
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L7" >}}
2525
{{< /tab >}}
2626
{{< tab header="CSharp" >}}driver.Title;{{< /tab >}}
27-
{{< tab header="Ruby" >}}driver.title{{< /tab >}}
27+
{{< tab header="Ruby" text=true >}}
28+
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
29+
{{< /tab >}}
2830
{{< tab header="JavaScript" text=true >}}
2931
{{< gh-codeblock path="examples/javascript/test/interactions/interactionsIndex.spec.js#L20" >}}
3032
{{< /tab >}}
@@ -44,7 +46,9 @@ Você pode ler a URL atual na barra de endereço do navegador usando:
4446
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L10" >}}
4547
{{< /tab >}}
4648
{{< tab header="CSharp" >}}driver.Url;{{< /tab >}}
47-
{{< tab header="Ruby" >}}driver.current_url{{< /tab >}}
49+
{{< tab header="Ruby" text=true >}}
50+
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L14" >}}
51+
{{< /tab >}}
4852
{{< tab header="JavaScript" text=true >}}
4953
{{< gh-codeblock path="examples/javascript/test/interactions/interactionsIndex.spec.js#L24" >}}
5054
{{< /tab >}}

website_and_docs/content/documentation/webdriver/interactions/_index.zh-cn.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ aliases: [
2323
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L7" >}}
2424
{{< /tab >}}
2525
{{< tab header="CSharp" >}}driver.Title;{{< /tab >}}
26-
{{< tab header="Ruby" >}}driver.title{{< /tab >}}
26+
{{< tab header="Ruby" text=true >}}
27+
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
28+
{{< /tab >}}
2729
{{< tab header="JavaScript" text=true >}}
2830
{{< gh-codeblock path="examples/javascript/test/interactions/interactionsIndex.spec.js#L20" >}}
2931
{{< /tab >}}
@@ -42,7 +44,9 @@ aliases: [
4244
{{< gh-codeblock path="examples/python/tests/interactions/test_interactions.py#L10" >}}
4345
{{< /tab >}}
4446
{{< tab header="CSharp" >}}driver.Url;{{< /tab >}}
45-
{{< tab header="Ruby" >}}driver.current_url{{< /tab >}}
47+
{{< tab header="Ruby" text=true >}}
48+
{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L14" >}}
49+
{{< /tab >}}
4650
{{< tab header="JavaScript" text=true >}}
4751
{{< gh-codeblock path="examples/javascript/test/interactions/interactionsIndex.spec.js#L24" >}}
4852
{{< /tab >}}

website_and_docs/content/documentation/webdriver/interactions/navigation.en.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ open your website. This can be achieved in a single line:
2323
{{< tab header="CSharp" text=true >}}
2424
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L17-L20" >}}
2525
{{< /tab >}}
26-
{{< tab header="Ruby" >}}
27-
driver.navigate.to 'https://selenium.dev'
28-
{{< /tab >}}
26+
{{< tab header="Ruby" text=true >}}
27+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L7-L9" >}}
28+
{{< /tab >}}
2929
{{< tab header="JavaScript" text=true >}}
3030
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L16-L20" >}}
3131
{{< /tab >}}
@@ -53,7 +53,9 @@ Pressing the browser's back button:
5353
{{< tab header="CSharp" text=true >}}
5454
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L24-L25" >}}
5555
{{< /tab >}}
56-
{{< tab header="Ruby" >}}driver.navigate.back{{< /tab >}}
56+
{{< tab header="Ruby" text=true >}}
57+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L15" >}}
58+
{{< /tab >}}
5759
{{< tab header="JavaScript" text=true >}}
5860
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L24-L25" >}}
5961
{{< /tab >}}
@@ -73,7 +75,9 @@ Pressing the browser's forward button:
7375
{{< tab header="CSharp" text=true >}}
7476
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L29-L30" >}}
7577
{{< /tab >}}
76-
{{< tab header="Ruby" >}}driver.navigate.forward{{< /tab >}}
78+
{{< tab header="Ruby" text=true >}}
79+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L23" >}}
80+
{{< /tab >}}
7781
{{< tab header="JavaScript" text=true >}}
7882
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L29-L30" >}}
7983
{{< /tab >}}
@@ -94,7 +98,9 @@ Refresh the current page:
9498
{{< tab header="CSharp" text=true >}}
9599
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L34-L35" >}}
96100
{{< /tab >}}
97-
{{< tab header="Ruby" >}}driver.navigate.refresh{{< /tab >}}
101+
{{< tab header="Ruby" text=true >}}
102+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L29" >}}
103+
{{< /tab >}}
98104
{{< tab header="JavaScript" text=true >}}
99105
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L34-L35" >}}
100106
{{< /tab >}}

website_and_docs/content/documentation/webdriver/interactions/navigation.ja.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ aliases: [
2222
{{< tab header="CSharp" text=true >}}
2323
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L17-L20" >}}
2424
{{< /tab >}}
25-
{{< tab header="Ruby" >}}
26-
# Convenient way
27-
driver.get 'https://selenium.dev'
28-
29-
# Longer Way
30-
driver.navigate.to 'https://selenium.dev'
31-
{{< /tab >}}
25+
{{< tab header="Ruby" text=true >}}
26+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L7-L9" >}}
27+
{{< /tab >}}
3228
{{< tab header="JavaScript" text=true >}}
3329
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L16-L20" >}}
3430
{{< /tab >}}
@@ -54,7 +50,9 @@ driver.navigate().to("https://selenium.dev")
5450
{{< tab header="CSharp" text=true >}}
5551
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L24-L25" >}}
5652
{{< /tab >}}
57-
{{< tab header="Ruby" >}}driver.navigate.back{{< /tab >}}
53+
{{< tab header="Ruby" text=true >}}
54+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L15" >}}
55+
{{< /tab >}}
5856
{{< tab header="JavaScript" text=true >}}
5957
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L24-L25" >}}
6058
{{< /tab >}}
@@ -76,7 +74,9 @@ driver.navigate().to("https://selenium.dev")
7674
{{< tab header="CSharp" text=true >}}
7775
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L29-L30" >}}
7876
{{< /tab >}}
79-
{{< tab header="Ruby" >}}driver.navigate.forward{{< /tab >}}
77+
{{< tab header="Ruby" text=true >}}
78+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L23" >}}
79+
{{< /tab >}}
8080
{{< tab header="JavaScript" text=true >}}
8181
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L29-L30" >}}
8282
{{< /tab >}}
@@ -98,7 +98,9 @@ driver.navigate().to("https://selenium.dev")
9898
{{< tab header="CSharp" text=true >}}
9999
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L34-L35" >}}
100100
{{< /tab >}}
101-
{{< tab header="Ruby" >}}driver.navigate.refresh{{< /tab >}}
101+
{{< tab header="Ruby" text=true >}}
102+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L29" >}}
103+
{{< /tab >}}
102104
{{< tab header="JavaScript" text=true >}}
103105
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L34-L35" >}}
104106
{{< /tab >}}

website_and_docs/content/documentation/webdriver/interactions/navigation.pt-br.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,9 @@ abrir o seu site. Isso pode ser feito em uma única linha, utilize o seguinte co
2323
{{< tab header="CSharp" text=true >}}
2424
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L17-L20" >}}
2525
{{< /tab >}}
26-
{{< tab header="Ruby" >}}
27-
# Convenient way
28-
driver.get 'https://selenium.dev'
29-
30-
# Longer Way
31-
driver.navigate.to 'https://selenium.dev'
32-
{{< /tab >}}
26+
{{< tab header="Ruby" text=true >}}
27+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L7-L9" >}}
28+
{{< /tab >}}
3329
{{< tab header="JavaScript" text=true >}}
3430
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L16-L20" >}}
3531
{{< /tab >}}
@@ -55,7 +51,9 @@ Pressionando o botão Voltar do navegador:
5551
{{< tab header="CSharp" text=true >}}
5652
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L24-L25" >}}
5753
{{< /tab >}}
58-
{{< tab header="Ruby" >}}driver.navigate.back{{< /tab >}}
54+
{{< tab header="Ruby" text=true >}}
55+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L15" >}}
56+
{{< /tab >}}
5957
{{< tab header="JavaScript" text=true >}}
6058
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L24-L25" >}}
6159
{{< /tab >}}
@@ -75,7 +73,9 @@ Pressionando o botão Avançar do navegador:
7573
{{< tab header="CSharp" text=true >}}
7674
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L29-L30" >}}
7775
{{< /tab >}}
78-
{{< tab header="Ruby" >}}driver.navigate.forward{{< /tab >}}
76+
{{< tab header="Ruby" text=true >}}
77+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L23" >}}
78+
{{< /tab >}}
7979
{{< tab header="JavaScript" text=true >}}
8080
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L29-L30" >}}
8181
{{< /tab >}}
@@ -96,7 +96,9 @@ Atualizando a página atual:
9696
{{< tab header="CSharp" text=true >}}
9797
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L34-L35" >}}
9898
{{< /tab >}}
99-
{{< tab header="Ruby" >}}driver.navigate.refresh{{< /tab >}}
99+
{{< tab header="Ruby" text=true >}}
100+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L29" >}}
101+
{{< /tab >}}
100102
{{< tab header="JavaScript" text=true >}}
101103
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L34-L35" >}}
102104
{{< /tab >}}

website_and_docs/content/documentation/webdriver/interactions/navigation.zh-cn.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ aliases: [
2222
{{< tab header="CSharp" text=true >}}
2323
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L17-L20" >}}
2424
{{< /tab >}}
25-
{{< tab header="Ruby" >}}
26-
# 简便的方法
27-
driver.get 'https://selenium.dev'
28-
29-
# 更长的方法
30-
driver.navigate.to 'https://selenium.dev'
25+
{{< tab header="Ruby" text=true >}}
26+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L7-L9" >}}
3127
{{< /tab >}}
3228
{{< tab header="JavaScript" text=true >}}
3329
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L16-L20" >}}
@@ -54,7 +50,9 @@ driver.navigate().to("https://selenium.dev")
5450
{{< tab header="CSharp" text=true >}}
5551
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L24-L25" >}}
5652
{{< /tab >}}
57-
{{< tab header="Ruby" >}}driver.navigate.back{{< /tab >}}
53+
{{< tab header="Ruby" text=true >}}
54+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L15" >}}
55+
{{< /tab >}}
5856
{{< tab header="JavaScript" text=true >}}
5957
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L24-L25" >}}
6058
{{< /tab >}}
@@ -74,7 +72,9 @@ driver.navigate().to("https://selenium.dev")
7472
{{< tab header="CSharp" text=true >}}
7573
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L29-L30" >}}
7674
{{< /tab >}}
77-
{{< tab header="Ruby" >}}driver.navigate.forward{{< /tab >}}
75+
{{< tab header="Ruby" text=true >}}
76+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L23" >}}
77+
{{< /tab >}}
7878
{{< tab header="JavaScript" text=true >}}
7979
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L29-L30" >}}
8080
{{< /tab >}}
@@ -94,7 +94,9 @@ driver.navigate().to("https://selenium.dev")
9494
{{< tab header="CSharp" text=true >}}
9595
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs#L34-L35" >}}
9696
{{< /tab >}}
97-
{{< tab header="Ruby" >}}driver.navigate.refresh{{< /tab >}}
97+
{{< tab header="Ruby" text=true >}}
98+
{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L29" >}}
99+
{{< /tab >}}
98100
{{< tab header="JavaScript" text=true >}}
99101
{{< gh-codeblock path="examples/javascript/test/interactions/navigation.spec.js#L34-L35" >}}
100102
{{< /tab >}}

0 commit comments

Comments
 (0)