Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c0f3224

Browse files
hiroksarkerdiemol
authored andcommitted
DesiredCapabilities, Local file detector using C# (#53)
* DesiredCapabilities, Local file detector using C# DesiredCapabilities , Local file detector using C# * Adding code sample in other translated languages, fixing ChromeOptions
1 parent 2eba263 commit c0f3224

File tree

6 files changed

+102
-38
lines changed

6 files changed

+102
-38
lines changed

‎docs_source_files/content/remote_webdriver/remote_webdriver_client.en.md‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ driver.quit();
7272
# We don't have a Python code sample yet - Help us out and raise a PR
7373
{{< / code-panel >}}
7474
{{< code-panel language="csharp" >}}
75-
// We don't have a C# code sample yet - Help us out and raise a PR
75+
var chromeOptions = new ChromeOptions();
76+
chromeOptions.BrowserVersion = "67";
77+
chromeOptions.PlatformName = "Windows XP";
78+
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), chromeOptions);
79+
driver.Navigate().GoToUrl("http://www.google.com");
80+
driver.Quit();
7681
{{< / code-panel >}}
7782
{{< code-panel language="ruby" >}}
7883
caps = Selenium::WebDriver::Remote::Capabilities.chrome
@@ -113,7 +118,11 @@ driver.setFileDetector(new LocalFileDetector());
113118
# We don't have a Python code sample yet - Help us out and raise a PR
114119
{{< / code-panel >}}
115120
{{< code-panel language="csharp" >}}
116-
// We don't have a C# code sample yet - Help us out and raise a PR
121+
var allowsDetection = this.driver as IAllowsFileDetection;
122+
if (allowsDetection != null)
123+
{
124+
allowsDetection.FileDetector = new LocalFileDetector();
125+
}
117126
{{< / code-panel >}}
118127
{{< code-panel language="ruby" >}}
119128
@driver.file_detector = lambda do |args|
@@ -142,7 +151,9 @@ upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
142151
# We don't have a Python code sample yet - Help us out and raise a PR
143152
{{< / code-panel >}}
144153
{{< code-panel language="csharp" >}}
145-
// We don't have a C# code sample yet - Help us out and raise a PR
154+
driver.Navigate().GoToUrl("http://sso.dev.saucelabs.com/test/guinea-file-upload");
155+
IWebElement upload = driver.FindElement(By.Id("myfile"));
156+
upload.SendKeys(@"/Users/sso/the/local/path/to/darkbulb.jpg");
146157
{{< / code-panel >}}
147158
{{< code-panel language="ruby" >}}
148159
@driver.navigate.to "http://sso.dev.saucelabs.com/test/guinea-file-upload"

‎docs_source_files/content/remote_webdriver/remote_webdriver_client.es.md‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ English to Spanish. Do you speak Spanish? Help us to translate
99
it by sending us pull requests!
1010
{{% /notice %}}
1111

12-
First, we need to connect to the RemoteWebDriver.
12+
To run a remote WebDriver client, we first need to connect to the RemoteWebDriver.
1313
We do this by pointing the URL to the address of the server running our tests.
1414
In order to customize our configuration, we set desired capabilities.
1515
Below is an example of instantiating a remote WebDriver object
@@ -31,7 +31,7 @@ driver.quit();
3131
IWebDriver driver = new RemoteWebDriver(new Uri("http://www.example.com"), firefoxOptions);
3232
driver.Navigate().GoToUrl("http://www.google.com");
3333
driver.Quit();
34-
{{< / code-panel >}}
34+
{{< / code-panel >}}
3535
{{< code-panel language="ruby" >}}
3636
require 'selenium-webdriver'
3737

@@ -78,7 +78,12 @@ driver.quit();
7878
# We don't have a Python code sample yet - Help us out and raise a PR
7979
{{< / code-panel >}}
8080
{{< code-panel language="csharp" >}}
81-
// We don't have a C# code sample yet - Help us out and raise a PR
81+
var chromeOptions = new ChromeOptions();
82+
chromeOptions.BrowserVersion = "67";
83+
chromeOptions.PlatformName = "Windows XP";
84+
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), chromeOptions);
85+
driver.Navigate().GoToUrl("http://www.google.com");
86+
driver.Quit();
8287
{{< / code-panel >}}
8388
{{< code-panel language="ruby" >}}
8489
caps = Selenium::WebDriver::Remote::Capabilities.chrome
@@ -119,7 +124,11 @@ driver.setFileDetector(new LocalFileDetector());
119124
# We don't have a Python code sample yet - Help us out and raise a PR
120125
{{< / code-panel >}}
121126
{{< code-panel language="csharp" >}}
122-
// We don't have a C# code sample yet - Help us out and raise a PR
127+
var allowsDetection = this.driver as IAllowsFileDetection;
128+
if (allowsDetection != null)
129+
{
130+
allowsDetection.FileDetector = new LocalFileDetector();
131+
}
123132
{{< / code-panel >}}
124133
{{< code-panel language="ruby" >}}
125134
@driver.file_detector = lambda do |args|
@@ -148,7 +157,9 @@ upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
148157
# We don't have a Python code sample yet - Help us out and raise a PR
149158
{{< / code-panel >}}
150159
{{< code-panel language="csharp" >}}
151-
// We don't have a C# code sample yet - Help us out and raise a PR
160+
driver.Navigate().GoToUrl("http://sso.dev.saucelabs.com/test/guinea-file-upload");
161+
IWebElement upload = driver.FindElement(By.Id("myfile"));
162+
upload.SendKeys(@"/Users/sso/the/local/path/to/darkbulb.jpg");
152163
{{< / code-panel >}}
153164
{{< code-panel language="ruby" >}}
154165
@driver.navigate.to "http://sso.dev.saucelabs.com/test/guinea-file-upload"
@@ -164,4 +175,3 @@ val upload: WebElement = driver.findElement(By.id("myfile"))
164175
upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg")
165176
{{< / code-panel >}}
166177
{{< / code-tab >}}
167-

‎docs_source_files/content/remote_webdriver/remote_webdriver_client.fr.md‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ English to French. Do you speak French? Help us to translate
99
it by sending us pull requests!
1010
{{% /notice %}}
1111

12-
First, we need to connect to the RemoteWebDriver.
12+
To run a remote WebDriver client, we first need to connect to the RemoteWebDriver.
1313
We do this by pointing the URL to the address of the server running our tests.
1414
In order to customize our configuration, we set desired capabilities.
1515
Below is an example of instantiating a remote WebDriver object
@@ -31,7 +31,7 @@ driver.quit();
3131
IWebDriver driver = new RemoteWebDriver(new Uri("http://www.example.com"), firefoxOptions);
3232
driver.Navigate().GoToUrl("http://www.google.com");
3333
driver.Quit();
34-
{{< / code-panel >}}
34+
{{< / code-panel >}}
3535
{{< code-panel language="ruby" >}}
3636
require 'selenium-webdriver'
3737

@@ -78,7 +78,12 @@ driver.quit();
7878
# We don't have a Python code sample yet - Help us out and raise a PR
7979
{{< / code-panel >}}
8080
{{< code-panel language="csharp" >}}
81-
// We don't have a C# code sample yet - Help us out and raise a PR
81+
var chromeOptions = new ChromeOptions();
82+
chromeOptions.BrowserVersion = "67";
83+
chromeOptions.PlatformName = "Windows XP";
84+
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), chromeOptions);
85+
driver.Navigate().GoToUrl("http://www.google.com");
86+
driver.Quit();
8287
{{< / code-panel >}}
8388
{{< code-panel language="ruby" >}}
8489
caps = Selenium::WebDriver::Remote::Capabilities.chrome
@@ -119,7 +124,11 @@ driver.setFileDetector(new LocalFileDetector());
119124
# We don't have a Python code sample yet - Help us out and raise a PR
120125
{{< / code-panel >}}
121126
{{< code-panel language="csharp" >}}
122-
// We don't have a C# code sample yet - Help us out and raise a PR
127+
var allowsDetection = this.driver as IAllowsFileDetection;
128+
if (allowsDetection != null)
129+
{
130+
allowsDetection.FileDetector = new LocalFileDetector();
131+
}
123132
{{< / code-panel >}}
124133
{{< code-panel language="ruby" >}}
125134
@driver.file_detector = lambda do |args|
@@ -148,7 +157,9 @@ upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
148157
# We don't have a Python code sample yet - Help us out and raise a PR
149158
{{< / code-panel >}}
150159
{{< code-panel language="csharp" >}}
151-
// We don't have a C# code sample yet - Help us out and raise a PR
160+
driver.Navigate().GoToUrl("http://sso.dev.saucelabs.com/test/guinea-file-upload");
161+
IWebElement upload = driver.FindElement(By.Id("myfile"));
162+
upload.SendKeys(@"/Users/sso/the/local/path/to/darkbulb.jpg");
152163
{{< / code-panel >}}
153164
{{< code-panel language="ruby" >}}
154165
@driver.navigate.to "http://sso.dev.saucelabs.com/test/guinea-file-upload"
@@ -164,4 +175,3 @@ val upload: WebElement = driver.findElement(By.id("myfile"))
164175
upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg")
165176
{{< / code-panel >}}
166177
{{< / code-tab >}}
167-

‎docs_source_files/content/remote_webdriver/remote_webdriver_client.ja.md‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ weight: 2
88
日本語は話せますか?プルリクエストをして翻訳を手伝ってください!
99
{{% /notice %}}
1010

11-
First, we need to connect to the RemoteWebDriver.
11+
To run a remote WebDriver client, we first need to connect to the RemoteWebDriver.
1212
We do this by pointing the URL to the address of the server running our tests.
1313
In order to customize our configuration, we set desired capabilities.
1414
Below is an example of instantiating a remote WebDriver object
@@ -30,7 +30,7 @@ driver.quit();
3030
IWebDriver driver = new RemoteWebDriver(new Uri("http://www.example.com"), firefoxOptions);
3131
driver.Navigate().GoToUrl("http://www.google.com");
3232
driver.Quit();
33-
{{< / code-panel >}}
33+
{{< / code-panel >}}
3434
{{< code-panel language="ruby" >}}
3535
require 'selenium-webdriver'
3636

@@ -77,7 +77,12 @@ driver.quit();
7777
# We don't have a Python code sample yet - Help us out and raise a PR
7878
{{< / code-panel >}}
7979
{{< code-panel language="csharp" >}}
80-
// We don't have a C# code sample yet - Help us out and raise a PR
80+
var chromeOptions = new ChromeOptions();
81+
chromeOptions.BrowserVersion = "67";
82+
chromeOptions.PlatformName = "Windows XP";
83+
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), chromeOptions);
84+
driver.Navigate().GoToUrl("http://www.google.com");
85+
driver.Quit();
8186
{{< / code-panel >}}
8287
{{< code-panel language="ruby" >}}
8388
caps = Selenium::WebDriver::Remote::Capabilities.chrome
@@ -118,7 +123,11 @@ driver.setFileDetector(new LocalFileDetector());
118123
# We don't have a Python code sample yet - Help us out and raise a PR
119124
{{< / code-panel >}}
120125
{{< code-panel language="csharp" >}}
121-
// We don't have a C# code sample yet - Help us out and raise a PR
126+
var allowsDetection = this.driver as IAllowsFileDetection;
127+
if (allowsDetection != null)
128+
{
129+
allowsDetection.FileDetector = new LocalFileDetector();
130+
}
122131
{{< / code-panel >}}
123132
{{< code-panel language="ruby" >}}
124133
@driver.file_detector = lambda do |args|
@@ -147,7 +156,9 @@ upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
147156
# We don't have a Python code sample yet - Help us out and raise a PR
148157
{{< / code-panel >}}
149158
{{< code-panel language="csharp" >}}
150-
// We don't have a C# code sample yet - Help us out and raise a PR
159+
driver.Navigate().GoToUrl("http://sso.dev.saucelabs.com/test/guinea-file-upload");
160+
IWebElement upload = driver.FindElement(By.Id("myfile"));
161+
upload.SendKeys(@"/Users/sso/the/local/path/to/darkbulb.jpg");
151162
{{< / code-panel >}}
152163
{{< code-panel language="ruby" >}}
153164
@driver.navigate.to "http://sso.dev.saucelabs.com/test/guinea-file-upload"

‎docs_source_files/content/remote_webdriver/remote_webdriver_client.nl.md‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ English to Dutch. Do you speak Dutch? Help us to translate
99
it by sending us pull requests!
1010
{{% /notice %}}
1111

12-
First, we need to connect to the RemoteWebDriver.
12+
To run a remote WebDriver client, we first need to connect to the RemoteWebDriver.
1313
We do this by pointing the URL to the address of the server running our tests.
1414
In order to customize our configuration, we set desired capabilities.
1515
Below is an example of instantiating a remote WebDriver object
@@ -31,7 +31,7 @@ driver.quit();
3131
IWebDriver driver = new RemoteWebDriver(new Uri("http://www.example.com"), firefoxOptions);
3232
driver.Navigate().GoToUrl("http://www.google.com");
3333
driver.Quit();
34-
{{< / code-panel >}}
34+
{{< / code-panel >}}
3535
{{< code-panel language="ruby" >}}
3636
require 'selenium-webdriver'
3737

@@ -78,7 +78,12 @@ driver.quit();
7878
# We don't have a Python code sample yet - Help us out and raise a PR
7979
{{< / code-panel >}}
8080
{{< code-panel language="csharp" >}}
81-
// We don't have a C# code sample yet - Help us out and raise a PR
81+
var chromeOptions = new ChromeOptions();
82+
chromeOptions.BrowserVersion = "67";
83+
chromeOptions.PlatformName = "Windows XP";
84+
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), chromeOptions);
85+
driver.Navigate().GoToUrl("http://www.google.com");
86+
driver.Quit();
8287
{{< / code-panel >}}
8388
{{< code-panel language="ruby" >}}
8489
caps = Selenium::WebDriver::Remote::Capabilities.chrome
@@ -119,7 +124,11 @@ driver.setFileDetector(new LocalFileDetector());
119124
# We don't have a Python code sample yet - Help us out and raise a PR
120125
{{< / code-panel >}}
121126
{{< code-panel language="csharp" >}}
122-
// We don't have a C# code sample yet - Help us out and raise a PR
127+
var allowsDetection = this.driver as IAllowsFileDetection;
128+
if (allowsDetection != null)
129+
{
130+
allowsDetection.FileDetector = new LocalFileDetector();
131+
}
123132
{{< / code-panel >}}
124133
{{< code-panel language="ruby" >}}
125134
@driver.file_detector = lambda do |args|
@@ -148,7 +157,9 @@ upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
148157
# We don't have a Python code sample yet - Help us out and raise a PR
149158
{{< / code-panel >}}
150159
{{< code-panel language="csharp" >}}
151-
// We don't have a C# code sample yet - Help us out and raise a PR
160+
driver.Navigate().GoToUrl("http://sso.dev.saucelabs.com/test/guinea-file-upload");
161+
IWebElement upload = driver.FindElement(By.Id("myfile"));
162+
upload.SendKeys(@"/Users/sso/the/local/path/to/darkbulb.jpg");
152163
{{< / code-panel >}}
153164
{{< code-panel language="ruby" >}}
154165
@driver.navigate.to "http://sso.dev.saucelabs.com/test/guinea-file-upload"

‎docs_source_files/content/remote_webdriver/remote_webdriver_client.zh-cn.md‎

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ weight: 2
88
您熟悉英语与简体中文吗?帮助我们翻译它,通过 pull requests 给我们!
99
{{% /notice %}}
1010

11-
First, we need to connect to the RemoteWebDriver.
11+
To run a remote WebDriver client, we first need to connect to the RemoteWebDriver.
1212
We do this by pointing the URL to the address of the server running our tests.
1313
In order to customize our configuration, we set desired capabilities.
1414
Below is an example of instantiating a remote WebDriver object
@@ -23,14 +23,14 @@ driver.get("http://www.google.com");
2323
driver.quit();
2424
{{< / code-panel >}}
2525
{{< code-panel language="python" >}}
26-
# We don't have a Python code sample yet - Help us out and raise a PR
26+
# We don't have a Python code sample yet - Help us out and raise a PR
2727
{{< / code-panel >}}
2828
{{< code-panel language="csharp" >}}
2929
FirefoxOptions firefoxOptions = new FirefoxOptions();
3030
IWebDriver driver = new RemoteWebDriver(new Uri("http://www.example.com"), firefoxOptions);
3131
driver.Navigate().GoToUrl("http://www.google.com");
3232
driver.Quit();
33-
{{< / code-panel >}}
33+
{{< / code-panel >}}
3434
{{< code-panel language="ruby" >}}
3535
require 'selenium-webdriver'
3636

@@ -39,7 +39,7 @@ driver.get "http://www.google.com"
3939
driver.close
4040
{{< / code-panel >}}
4141
{{< code-panel language="javascript" >}}
42-
// We don't have a JavaScript code sample yet - Help us out and raise a PR
42+
// We don't have a JavaScript code sample yet - Help us out and raise a PR
4343
{{< / code-panel >}}
4444
{{< code-panel language="kotlin" >}}
4545
firefoxOptions = FirefoxOptions()
@@ -74,10 +74,15 @@ driver.get("http://www.google.com");
7474
driver.quit();
7575
{{< / code-panel >}}
7676
{{< code-panel language="python" >}}
77-
# We don't have a Python code sample yet - Help us out and raise a PR
77+
# We don't have a Python code sample yet - Help us out and raise a PR
7878
{{< / code-panel >}}
7979
{{< code-panel language="csharp" >}}
80-
// We don't have a C# code sample yet - Help us out and raise a PR
80+
var chromeOptions = new ChromeOptions();
81+
chromeOptions.BrowserVersion = "67";
82+
chromeOptions.PlatformName = "Windows XP";
83+
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), chromeOptions);
84+
driver.Navigate().GoToUrl("http://www.google.com");
85+
driver.Quit();
8186
{{< / code-panel >}}
8287
{{< code-panel language="ruby" >}}
8388
caps = Selenium::WebDriver::Remote::Capabilities.chrome
@@ -87,7 +92,7 @@ caps.version = 67
8792
driver = Selenium::WebDriver.for :remote, :url => "http://www.example.com", :desired_capabilities => caps
8893
{{< / code-panel >}}
8994
{{< code-panel language="javascript" >}}
90-
// We don't have a JavaScript code sample yet - Help us out and raise a PR
95+
// We don't have a JavaScript code sample yet - Help us out and raise a PR
9196
{{< / code-panel >}}
9297
{{< code-panel language="kotlin" >}}
9398
val chromeOptions = ChromeOptions()
@@ -115,10 +120,14 @@ the following way:
115120
driver.setFileDetector(new LocalFileDetector());
116121
{{< / code-panel >}}
117122
{{< code-panel language="python" >}}
118-
# We don't have a Python code sample yet - Help us out and raise a PR
123+
# We don't have a Python code sample yet - Help us out and raise a PR
119124
{{< / code-panel >}}
120125
{{< code-panel language="csharp" >}}
121-
// We don't have a C# code sample yet - Help us out and raise a PR
126+
var allowsDetection = this.driver as IAllowsFileDetection;
127+
if (allowsDetection != null)
128+
{
129+
allowsDetection.FileDetector = new LocalFileDetector();
130+
}
122131
{{< / code-panel >}}
123132
{{< code-panel language="ruby" >}}
124133
@driver.file_detector = lambda do |args|
@@ -128,7 +137,7 @@ driver.setFileDetector(new LocalFileDetector());
128137
end
129138
{{< / code-panel >}}
130139
{{< code-panel language="javascript" >}}
131-
// We don't have a JavaScript code sample yet - Help us out and raise a PR
140+
// We don't have a JavaScript code sample yet - Help us out and raise a PR
132141
{{< / code-panel >}}
133142
{{< code-panel language="kotlin" >}}
134143
driver.setFileDetector(new LocalFileDetector())
@@ -144,18 +153,20 @@ WebElement upload = driver.findElement(By.id("myfile"));
144153
upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
145154
{{< / code-panel >}}
146155
{{< code-panel language="python" >}}
147-
# We don't have a Python code sample yet - Help us out and raise a PR
156+
# We don't have a Python code sample yet - Help us out and raise a PR
148157
{{< / code-panel >}}
149158
{{< code-panel language="csharp" >}}
150-
// We don't have a C# code sample yet - Help us out and raise a PR
159+
driver.Navigate().GoToUrl("http://sso.dev.saucelabs.com/test/guinea-file-upload");
160+
IWebElement upload = driver.FindElement(By.Id("myfile"));
161+
upload.SendKeys(@"/Users/sso/the/local/path/to/darkbulb.jpg");
151162
{{< / code-panel >}}
152163
{{< code-panel language="ruby" >}}
153164
@driver.navigate.to "http://sso.dev.saucelabs.com/test/guinea-file-upload"
154165
element = @driver.find_element(:id, 'myfile')
155166
element.send_keys "/Users/sso/SauceLabs/sauce/hostess/maitred/maitred/public/images/darkbulb.jpg"
156167
{{< / code-panel >}}
157168
{{< code-panel language="javascript" >}}
158-
// We don't have a JavaScript code sample yet - Help us out and raise a PR
169+
// We don't have a JavaScript code sample yet - Help us out and raise a PR
159170
{{< / code-panel >}}
160171
{{< code-panel language="kotlin" >}}
161172
driver.get("http://sso.dev.saucelabs.com/test/guinea-file-upload")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /