Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SeleniumTraining
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qazi Zain
SeleniumTraining
Commits
e0f176c5
Commit
e0f176c5
authored
Nov 15, 2024
by
Qazi Zain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
in Streams sorting code is added
parent
a1af2b36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
Alerts.java
src/test/java/Streams/Alerts.java
+33
-0
Sorting.java
src/test/java/Streams/Sorting.java
+44
-0
No files found.
src/test/java/Streams/Alerts.java
0 → 100644
View file @
e0f176c5
package
Streams
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.firefox.FirefoxDriver
;
public
class
Alerts
{
public
static
void
main
(
String
[]
args
)
{
WebDriver
obj
=
new
FirefoxDriver
();
obj
.
get
(
"https://rahulshettyacademy.com/AutomationPractice/"
);
WebElement
alertButton
=
obj
.
findElement
(
By
.
id
(
"alertbtn"
));
alertButton
.
click
();
// now switch from window to alert for handle.
obj
.
switchTo
().
alert
().
accept
();
// now click on confirm button
WebElement
confirmButton
=
obj
.
findElement
(
By
.
id
(
"confirmbtn"
));
confirmButton
.
click
();
obj
.
switchTo
().
alert
().
dismiss
();
}
}
src/test/java/Streams/Sorting.java
0 → 100644
View file @
e0f176c5
package
Streams
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.firefox.FirefoxDriver
;
import
org.testng.Assert
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
public
class
Sorting
{
public
static
void
main
(
String
[]
args
)
{
WebDriver
obj
=
new
FirefoxDriver
();
obj
.
get
(
"https://rahulshettyacademy.com/greenkart/#/offers"
);
obj
.
findElement
(
By
.
xpath
(
"//tr/th[1]"
)).
click
();
// Capturing List .
List
<
WebElement
>
webList
=
obj
.
findElements
(
By
.
xpath
(
"//tr/th[1]"
));
// not storing in it arrayList.
List
<
String
>
realList
=
new
ArrayList
<>();
for
(
WebElement
e:
webList
)
{
realList
.
add
(
e
.
getText
());
// this will extract the text of web Element and store in List.
}
List
<
String
>
sortedList
=
new
ArrayList
<>(
realList
);
Collections
.
sort
(
sortedList
);
// Creating Test using Assertion.
Assert
.
assertEquals
(
realList
,
sortedList
);
// if match then pass else fail.
}
}
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