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
84875cf7
Commit
84875cf7
authored
Nov 11, 2024
by
Qazi Zain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added A practice test , using Assertion and Explicit wait
parent
08a5f2c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
6 deletions
+71
-6
Practice.java
src/test/java/FunctionalTesting/Practice.java
+68
-0
WebElementAutomation.java
...hniques_to_automate_web_Element/WebElementAutomation.java
+3
-6
No files found.
src/test/java/FunctionalTesting/Practice.java
0 → 100644
View file @
84875cf7
package
FunctionalTesting
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.firefox.FirefoxDriver
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
import
org.testng.asserts.SoftAssert
;
import
java.time.Duration
;
public
class
Practice
{
public
static
void
main
(
String
[]
args
)
{
WebDriver
obj
=
new
FirefoxDriver
();
obj
.
get
(
"https://rahulshettyacademy.com/seleniumPractise/#/"
);
WebDriverWait
object
=
new
WebDriverWait
(
obj
,
Duration
.
ofSeconds
(
2
));
WebElement
button
;
SoftAssert
test
=
new
SoftAssert
();
WebElement
broklebutton
=
obj
.
findElement
(
By
.
xpath
(
"//div[@class='products-wrapper']/div/div/h4[text()='Brocolli - 1 Kg']/following-sibling::div[@class='stepper-input']/a[@class='increment'][1]"
));
WebElement
culiFlower
=
obj
.
findElement
(
By
.
xpath
(
"//div[@class='products-wrapper']/div/div/h4[text()='Cauliflower - 1 Kg']/following-sibling::div[@class='stepper-input']/a[@class='increment'][1]"
));
for
(
int
i
=
1
;
i
<=
3
;
i
++)
{
String
buttonXPath
=
"(//div[@class='product-action']/button)["
+
i
+
"]"
;
button
=
object
.
until
(
ExpectedConditions
.
elementToBeClickable
(
By
.
xpath
(
buttonXPath
)));
if
(
i
==
1
)
{
int
j
;
for
(
j
=
1
;
j
<=
5
;
j
++)
{
object
.
until
(
ExpectedConditions
.
elementToBeClickable
(
broklebutton
));
broklebutton
.
click
();
}
test
.
assertTrue
(
j
==
2
,
"5 items added in cart"
);
button
.
click
();
}
else
if
(
i
==
2
)
{
int
j
;
for
(
j
=
1
;
j
<=
7
;
j
++)
{
object
.
until
(
ExpectedConditions
.
elementToBeClickable
(
culiFlower
));
culiFlower
.
click
();
}
test
.
assertFalse
(
j
>
3
,
"If not meets return false"
);
button
.
click
();
}
}
test
.
assertAll
();
}
}
src/test/java/Techniques_to_automate_web_Element/WebElementAutomation.java
View file @
84875cf7
...
@@ -20,13 +20,10 @@ public class WebElementAutomation {
...
@@ -20,13 +20,10 @@ public class WebElementAutomation {
WebElement
object
=
obj
.
findElement
(
By
.
cssSelector
(
"select#ctl00_mainContent_DropDownListCurrency"
));
WebElement
object
=
obj
.
findElement
(
By
.
cssSelector
(
"select#ctl00_mainContent_DropDownListCurrency"
));
Select
StaticDropDown
=
new
Select
(
object
);
Select
ob
=
new
Select
(
object
);
StaticDropDown
.
selectByIndex
(
2
);
System
.
out
.
println
(
StaticDropDown
.
getFirstSelectedOption
().
getText
());
StaticDropDown
.
selectByValue
(
"INR"
);
System
.
out
.
println
(
StaticDropDown
.
getFirstSelectedOption
().
getText
());
ob
.
selectByIndex
(
1
);
ob
.
selectByValue
(
"AED"
);
//------------------------------------> updated Static DropDown <-------------------------------------------
//------------------------------------> updated Static DropDown <-------------------------------------------
...
...
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