Skip to content

Commit 36f7507

Browse files
committed
Add documentation for the remote webdriver examples
1 parent a890964 commit 36f7507

File tree

8 files changed

+906
-1149
lines changed

8 files changed

+906
-1149
lines changed

website_and_docs/content/documentation/webdriver/drivers/remote_webdriver.en.md

Lines changed: 208 additions & 216 deletions
Large diffs are not rendered by default.

website_and_docs/content/documentation/webdriver/drivers/remote_webdriver.ja.md

Lines changed: 208 additions & 201 deletions
Large diffs are not rendered by default.

website_and_docs/content/documentation/webdriver/drivers/remote_webdriver.pt-br.md

Lines changed: 206 additions & 209 deletions
Large diffs are not rendered by default.

website_and_docs/content/documentation/webdriver/drivers/remote_webdriver.zh-cn.md

Lines changed: 207 additions & 208 deletions
Large diffs are not rendered by default.

website_and_docs/content/documentation/webdriver/elements/file_upload.en.md

Lines changed: 20 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -7,89 +7,29 @@ aliases: [
77
]
88
---
99

10-
The file upload dialog could be handled using Selenium,
11-
when the input element is of type file.
12-
An example of it, could be found on this
13-
web page- https://the-internet.herokuapp.com/upload
14-
We will require to have a file available with us,
15-
which we need to upload.
16-
The code to upload the file for different programming
17-
languages will be as follows -
18-
19-
20-
{{< tabpane langEqualsHeader=true >}}
21-
{{< badge-examples >}}
22-
{{< tab header="Java" text=true >}}
23-
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/FileUploadTest.java#L26-L27">}}
24-
{{< /tab >}}
25-
{{< tab header="Python" >}}
26-
from selenium import webdriver
27-
driver.implicitly_wait(10)
28-
driver.get("https://the-internet.herokuapp.com/upload")
29-
driver.find_element(By.ID,"file-upload").send_keys("selenium-snapshot.jpg")
30-
driver.find_element(By.ID,"file-submit").submit()
31-
if(driver.page_source.find("File Uploaded!")):
32-
print("file upload success")
33-
else:
34-
print("file upload not successful")
35-
driver.quit()
36-
37-
{{< /tab >}}
38-
{{< tab header="CSharp" >}}
39-
using System;
40-
using OpenQA.Selenium;
41-
using OpenQA.Selenium.Chrome;
42-
43-
namespace SeleniumDocumentation.SeleniumPRs
44-
{
45-
class FileUploadExample
46-
{
47-
static void Main(String[] args)
48-
{
49-
IWebDriver driver = new ChromeDriver();
50-
try
51-
{
52-
// Navigate to Url
53-
driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/upload");
54-
driver.FindElement(By.Id("file-upload")).SendKeys("selenium-snapshot.jpg");
55-
driver.FindElement(By.Id("file-submit")).Submit();
56-
if (driver.PageSource.Contains("File Uploaded!"))
57-
{
58-
Console.WriteLine("file uploaded");
59-
}
60-
else
61-
{
62-
Console.WriteLine("file not uploaded");
63-
}
64-
driver.Quit();
65-
66-
}
67-
68-
}
69-
}
70-
71-
{{< /tab >}}
10+
Because Selenium cannot interact with the file upload dialog, it provides a way
11+
to upload files without opening the dialog. If the element is an `input` element with type `file`,
12+
you can use the send keys method to send the full path to the file that will be uploaded.
7213

14+
{{< tabpane text=true langEqualsHeader=true >}}
15+
{{< tab header="Java" >}}
16+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/FileUploadTest.java#L17-L19" >}}
17+
{{< /tab >}}
18+
{{% tab header="Python" %}}
19+
{{< gh-codeblock path="examples/python/tests/elements/test_file_upload.py#L12-L14" >}}
20+
{{% /tab %}}
21+
{{< tab header="CSharp" >}}
22+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/FileUploadTest.cs#L21-L23" >}}
23+
{{< /tab >}}
7324
{{< tab header="Ruby" >}}
74-
require 'selenium-webdriver'
75-
driver = Selenium::WebDriver.for :chrome
76-
driver.get("https://the-internet.herokuapp.com/upload")
77-
driver.find_element(:id,"file-upload").send_keys("selenium-snapshot.jpg")
78-
driver.find_element(:id,"file-submit").submit()
79-
80-
if driver.page_source().include? "File Uploaded!"
81-
puts "file upload success"
82-
else
83-
puts "file upload not successful"
84-
end
85-
86-
{{< /tab >}}
87-
88-
{{< tab header="JavaScript" text=true >}}
89-
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L22-L25">}}
25+
{{< gh-codeblock path="examples/ruby/spec/elements/file_upload_spec.rb#L12-L14" >}}
26+
{{< /tab >}}
27+
{{< tab header="JavaScript" >}}
28+
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L24-L25">}}
9029
{{< /tab >}}
91-
9230
{{< tab header="Kotlin" >}}
31+
{{< badge-examples >}}
32+
```java
9333
import org.openqa.selenium.By
9434
import org.openqa.selenium.chrome.ChromeDriver
9535

@@ -105,8 +45,6 @@ fun main() {
10545
println("file not uploaded")
10646
}
10747
}
48+
```
10849
{{< /tab >}}
10950
{{< /tabpane >}}
110-
111-
So the above example code helps to understand
112-
how we can upload a file using Selenium.

website_and_docs/content/documentation/webdriver/elements/file_upload.ja.md

Lines changed: 19 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -8,87 +8,29 @@ aliases: [
88
---
99

1010

11-
The file upload dialog could be handled using Selenium,
12-
when the input element is of type file.
13-
An example of it, could be found on this
14-
web page- https://the-internet.herokuapp.com/upload
15-
We will require to have a file available with us,
16-
which we need to upload.
17-
The code to upload the file for different programming
18-
languages will be as follows -
11+
Because Selenium cannot interact with the file upload dialog, it provides a way
12+
to upload files without opening the dialog. If the element is an `input` element with type `file`,
13+
you can use the send keys method to send the full path to the file that will be uploaded.
1914

20-
{{< tabpane langEqualsHeader=true >}}
21-
{{< tab header="Java" text=true >}}
22-
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/FileUploadTest.java#L26-L27">}}
15+
{{< tabpane text=true langEqualsHeader=true >}}
16+
{{< tab header="Java" >}}
17+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/FileUploadTest.java#L17-L19" >}}
18+
{{< /tab >}}
19+
{{% tab header="Python" %}}
20+
{{< gh-codeblock path="examples/python/tests/elements/test_file_upload.py#L12-L14" >}}
21+
{{% /tab %}}
22+
{{< tab header="CSharp" >}}
23+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/FileUploadTest.cs#L21-L23" >}}
2324
{{< /tab >}}
24-
{{< tab header="Python" >}}
25-
from selenium import webdriver
26-
driver.implicitly_wait(10)
27-
driver.get("https://the-internet.herokuapp.com/upload")
28-
driver.find_element(By.ID,"file-upload").send_keys("selenium-snapshot.jpg")
29-
driver.find_element(By.ID,"file-submit").submit()
30-
if(driver.page_source.find("File Uploaded!")):
31-
print("file upload success")
32-
else:
33-
print("file upload not successful")
34-
driver.quit()
35-
36-
{{< /tab >}}
37-
{{< tab header="CSharp" >}}
38-
using System;
39-
using OpenQA.Selenium;
40-
using OpenQA.Selenium.Chrome;
41-
42-
namespace SeleniumDocumentation.SeleniumPRs
43-
{
44-
class FileUploadExample
45-
{
46-
static void Main(String[] args)
47-
{
48-
IWebDriver driver = new ChromeDriver();
49-
try
50-
{
51-
// Navigate to Url
52-
driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/upload");
53-
driver.FindElement(By.Id("file-upload")).SendKeys("selenium-snapshot.jpg");
54-
driver.FindElement(By.Id("file-submit")).Submit();
55-
if (driver.PageSource.Contains("File Uploaded!"))
56-
{
57-
Console.WriteLine("file uploaded");
58-
}
59-
else
60-
{
61-
Console.WriteLine("file not uploaded");
62-
}
63-
driver.Quit();
64-
65-
}
66-
67-
}
68-
}
69-
70-
{{< /tab >}}
71-
7225
{{< tab header="Ruby" >}}
73-
require 'selenium-webdriver'
74-
driver = Selenium::WebDriver.for :chrome
75-
driver.get("https://the-internet.herokuapp.com/upload")
76-
driver.find_element(:id,"file-upload").send_keys("selenium-snapshot.jpg")
77-
driver.find_element(:id,"file-submit").submit()
78-
79-
if driver.page_source().include? "File Uploaded!"
80-
puts "file upload success"
81-
else
82-
puts "file upload not successful"
83-
end
84-
85-
{{< /tab >}}
86-
87-
{{< tab header="JavaScript" text=true >}}
88-
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L22-L25">}}
26+
{{< gh-codeblock path="examples/ruby/spec/elements/file_upload_spec.rb#L12-L14" >}}
27+
{{< /tab >}}
28+
{{< tab header="JavaScript" >}}
29+
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L24-L25">}}
8930
{{< /tab >}}
90-
9131
{{< tab header="Kotlin" >}}
32+
{{< badge-examples >}}
33+
```java
9234
import org.openqa.selenium.By
9335
import org.openqa.selenium.chrome.ChromeDriver
9436

@@ -104,8 +46,6 @@ fun main() {
10446
println("file not uploaded")
10547
}
10648
}
49+
```
10750
{{< /tab >}}
10851
{{< /tabpane >}}
109-
110-
So the above example code helps to understand
111-
how we can upload a file using Selenium.

website_and_docs/content/documentation/webdriver/elements/file_upload.pt-br.md

Lines changed: 19 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,85 +10,29 @@ description: >
1010
1111
---
1212

13-
A caixa de diálogo para o envio de arquivos pode ser tratada com o Selenium, quando o elemento de entrada é do tipo "file".
14-
Pode observar um exemplo neste link https://the-internet.herokuapp.com/upload .
13+
Because Selenium cannot interact with the file upload dialog, it provides a way
14+
to upload files without opening the dialog. If the element is an `input` element with type `file`,
15+
you can use the send keys method to send the full path to the file that will be uploaded.
1516

16-
Será necessário ter o arquivo a subir disponível para a operação.
17-
Apresentamos alguns exemplos de código para subir os arquivos em diversas linguagens de programação:
18-
19-
20-
{{< tabpane langEqualsHeader=true >}}
21-
{{< tab header="Java" text=true >}}
22-
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/FileUploadTest.java#L26-L27">}}
17+
{{< tabpane text=true langEqualsHeader=true >}}
18+
{{< tab header="Java" >}}
19+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/FileUploadTest.java#L17-L19" >}}
20+
{{< /tab >}}
21+
{{% tab header="Python" %}}
22+
{{< gh-codeblock path="examples/python/tests/elements/test_file_upload.py#L12-L14" >}}
23+
{{% /tab %}}
24+
{{< tab header="CSharp" >}}
25+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/FileUploadTest.cs#L21-L23" >}}
2326
{{< /tab >}}
24-
{{< tab header="Python" >}}
25-
from selenium import webdriver
26-
driver.implicitly_wait(10)
27-
driver.get("https://the-internet.herokuapp.com/upload")
28-
driver.find_element(By.ID,"file-upload").send_keys("selenium-snapshot.jpg")
29-
driver.find_element(By.ID,"file-submit").submit()
30-
if(driver.page_source.find("File Uploaded!")):
31-
print("file upload success")
32-
else:
33-
print("file upload not successful")
34-
driver.quit()
35-
36-
{{< /tab >}}
37-
{{< tab header="CSharp" >}}
38-
using System;
39-
using OpenQA.Selenium;
40-
using OpenQA.Selenium.Chrome;
41-
42-
namespace SeleniumDocumentation.SeleniumPRs
43-
{
44-
class FileUploadExample
45-
{
46-
static void Main(String[] args)
47-
{
48-
IWebDriver driver = new ChromeDriver();
49-
try
50-
{
51-
// Navigate to Url
52-
driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/upload");
53-
driver.FindElement(By.Id("file-upload")).SendKeys("selenium-snapshot.jpg");
54-
driver.FindElement(By.Id("file-submit")).Submit();
55-
if (driver.PageSource.Contains("File Uploaded!"))
56-
{
57-
Console.WriteLine("file uploaded");
58-
}
59-
else
60-
{
61-
Console.WriteLine("file not uploaded");
62-
}
63-
driver.Quit();
64-
65-
}
66-
67-
}
68-
}
69-
70-
{{< /tab >}}
71-
7227
{{< tab header="Ruby" >}}
73-
require 'selenium-webdriver'
74-
driver = Selenium::WebDriver.for :chrome
75-
driver.get("https://the-internet.herokuapp.com/upload")
76-
driver.find_element(:id,"file-upload").send_keys("selenium-snapshot.jpg")
77-
driver.find_element(:id,"file-submit").submit()
78-
79-
if driver.page_source().include? "File Uploaded!"
80-
puts "file upload success"
81-
else
82-
puts "file upload not successful"
83-
end
84-
85-
{{< /tab >}}
86-
87-
{{< tab header="JavaScript" text=true >}}
88-
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L22-L25">}}
28+
{{< gh-codeblock path="examples/ruby/spec/elements/file_upload_spec.rb#L12-L14" >}}
29+
{{< /tab >}}
30+
{{< tab header="JavaScript" >}}
31+
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L24-L25">}}
8932
{{< /tab >}}
90-
9133
{{< tab header="Kotlin" >}}
34+
{{< badge-examples >}}
35+
```java
9236
import org.openqa.selenium.By
9337
import org.openqa.selenium.chrome.ChromeDriver
9438

@@ -104,7 +48,6 @@ fun main() {
10448
println("file not uploaded")
10549
}
10650
}
51+
```
10752
{{< /tab >}}
10853
{{< /tabpane >}}
109-
110-
Esperamos que estes exemplos de código possam ajudar a compreender como subir um arquivo com Selenium.

0 commit comments

Comments
 (0)