Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
seleniumproj17
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sprakash4460
seleniumproj17
Commits
9bf87639
Commit
9bf87639
authored
Jul 20, 2019
by
Siva Rama Krishna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remote driver sample code
parent
b2799486
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
7 deletions
+37
-7
pom.xml
pom.xml
+1
-1
DemoApplication.java
src/main/java/com/example/demo/DemoApplication.java
+36
-6
No files found.
pom.xml
View file @
9bf87639
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
<maven.compiler.target>
1.8
</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<selenium.version>
2.53.1
</selenium.version>
<selenium.version>
3.141.59
</selenium.version>
<testng.version>
6.8
</testng.version>
<testng.version>
6.8
</testng.version>
</properties>
</properties>
<dependencies>
<dependencies>
...
...
src/main/java/com/example/demo/DemoApplication.java
View file @
9bf87639
package
com
.
example
.
demo
;
package
com
.
example
.
demo
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.chrome.ChromeOptions
;
import
org.openqa.selenium.chrome.ChromeOptions
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
import
org.openqa.selenium.remote.RemoteWebDriver
;
public
class
DemoApplication
{
public
class
DemoApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
throws
MalformedURLException
{
System
.
setProperty
(
"webdriver.chrome.driver"
,
"/home/user/chromedriver"
);
launchBrowserInNormalMode
();
ChromeOptions
chromeOptions
=
new
ChromeOptions
();
}
// chromeOptions.addArguments("--headless");
private
static
void
launchBrowserInNormalMode
()
throws
MalformedURLException
{
// In this mode we would be connecting to remote web driver(similar to selenium
// grid) meaning the script would be executed in the remote server.
// Below is the sample code to initialize the web driver.
String
remoteDriverHost
=
"https://pgtest.altimetrik.com/SERVICE_NAME"
;
// To see live execution of the script in browser please open the link
// `{remoteDriverHost}/grid/admin/live`
// To view more details of the execution Please open the link
// `{remoteDriverHost}/dashboard/`
DesiredCapabilities
dc
=
DesiredCapabilities
.
chrome
();
RemoteWebDriver
driver
=
new
RemoteWebDriver
(
new
URL
(
remoteDriverHost
+
"/wd/hub"
),
dc
);
dc
.
setCapability
(
"name"
,
"BrowserMode"
);
// Continue with test case scripting.
driver
.
navigate
().
to
(
"https://www.google.com/"
);
System
.
out
.
println
(
"Application title is "
+
driver
.
getTitle
());
driver
.
quit
();
}
private
static
void
launchBrowserInHeadlessMode
()
{
// The browser won't be visible instead it would running in the background.
// Below is the sample code to initialize the web driver.
System
.
setProperty
(
"webdriver.chrome.driver"
,
"/home/user/chromedriver"
);
ChromeOptions
chromeOptions
=
new
ChromeOptions
();
chromeOptions
.
addArguments
(
"--no-sandbox"
);
chromeOptions
.
addArguments
(
"--no-sandbox"
);
WebDriver
driver
=
new
ChromeDriver
(
chromeOptions
);
WebDriver
driver
=
new
ChromeDriver
(
chromeOptions
);
// Continue with test case scripting.
driver
.
navigate
().
to
(
"http://google.com"
);
driver
.
navigate
().
to
(
"http://google.com"
);
System
.
out
.
println
(
"Application title is "
+
driver
.
getTitle
());
System
.
out
.
println
(
"Application title is "
+
driver
.
getTitle
());
driver
.
quit
();
driver
.
quit
();
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment