S-Public Class PPT: File Lists Driversetup Java Customizedkpath Jjava
S-Public Class PPT: File Lists Driversetup Java Customizedkpath Jjava
S-Public Class PPT: File Lists Driversetup Java Customizedkpath Jjava
Lmport ors-openga.selenium.5y
ampport onE-Openga.selenium.NebD er
S import ong.openga.selenium.WebElement
ui.Select;
6 import org-openqa. selenium. support.
S-public class Customizedxpath /Do ppt change
d r i v e r = DriverSetup .getDriver()i
eturn driver;
/*Invoke the Webdriver/
/"store i t in static variable "driver and return i t
Activate Window
Go to Settings to acti
cognzanttekstaccom/mod/plforms/edit,php?id- 205008tuserid-63622#
Al
File List So Compile & Run Evaluate Restore Description
Driversetup.java 0
CustomizedXpath.java
s t o n e i t 1n s t a t c variable and return it"/
26
'driver
63622
public void setNewFormValues (String weight, String transportMode)
driver.findElement(By
transportMode
-xpath(7/input [@id='weight']")).sendkeys(weight);
transportMode,toLowercase(Q5
driver.findElement (By . xpath"77input[aid-"+transportMode+])).click)
/I Get the weight and the transport mode passed as
parameter
transportMode can either Air/Road/ship
be
I The
/ IBased on the transportMode, click the radio button
choose t h e a i a d i o button
39
46
For ex: If transportMode is"Air
// submit the form
(By. id("calculate")).click();
driver. findElementfind and the text.
message displayed
the element of the get
/7 After submit,
44 result driver.findElement
=
(By.id(result)getrext )3
45 /7 Store the retrieved text in result static variable.
47
48
49 Activate
50 public List<WebElement> textBoxCount() Go to Set
51
52 textBoxxpath =By.xpath("//input [atype="text 1)
public ListcwebElements textBOxCount) t
52 Getthe size of the textBoxList (total text box count) and store it in a static variable textBoxcount" then
b6
67
b8
Tdentify the text field labels by customi.zed xpath and print how many labels in the page using List
labelxpath1 By.xpath("//center/table/tbody/tr[1]/tdtil");
WebElement 11 = driver.findElement (1abelxpath1);
co9nzantrekstccom dpomeditphpia205008useridassi620
File List pae &Run Evaluate Restore Description
Briversetupjave CustomizedNpeth.java 0
69
pubac astcwebElement> labelscount( { 6S622
T d e n t i t y the text field labels by customized xpath and print how many labels in the page using L i s t
79
labelsiist.add(11);
labelsList.add(12);
IabelsList driver.
labelscount
findElements (By.xpath("/html/body/centen/table/tbody/tr/tdt21"))
labelsList.size()
System.out.println(labelsCount);
return labelsList;
I / Get the 1ist of all labels and store thatin a list labelslist (Use customized xpath locator to identify the elem
Get the size of the labelsList' (total label count) and store it in a staic variable
1abelsCount then print it
1 Return the list labelstist'
6302
public List<webElement> buttonCount () { Activate Windo
Go to Settings to at
buttonxpath - By.xpath("//button[@id- 'calculate ]")
Asss
escco oc/pl/torms/editphp?id= 20s008userid-63622
File List Compile & Run Evaluate RestoreP Description
Drversetup-java CustomizedXpath.java
ubiic. L1stcwebElement> buttonCount () 63622
95 buttonxpath = B y .x p a t h 7 / b u t t o n [ @ i d c a l c u l a t e ' ] " )
L06
1 Get the size of the "buttontist (total button count) and store it in a static variable 'buttoncount then print i t
107
188 IReturn the list "buttonList"
169
110
118
119 System.out.println(radiobuttoncount);
T
cognitant tekstac com/mod/vpliorms/edit.php?id- 20s008userid -636228
Fie ListSe Compile & Run Evaluate Restore Description
DriverSetup.java0 CUstomizedXpath.java 0
229
68622
public ListcWebElement> linkCount ()
and how 1inks in t h e pag using L i s t
/7 Identify the 1inks by customized xpath print many
149
'1inksList" DOZ
150 /Return the list
151
152 Activate Ni
153 Go to Setngs
154
155 public void closeBrowser (){
156
157
COghizanttekstoc.commod/vpioms/edit phpirdm205008useridm63622
File List
Compile & Run Evaluate Restore Description
Dnversetup.java CustomizedXpath.java
155- public void
closeBrows er(){
156
157
158
driver . quit ()5
//close browser
159
166
162
63622
public static void main(String[] args){
63622
163
178 e-OUt.printin(ncount);
179
188
181
unt prntoptlons.linkcount().size();
System.out.printinacount)O
Call the
63622
Call
method text Boxcount() and print the
size of the 1ist returned
the method 1abelscount() and print the
size of the 1ist returned
caii t h e method buttoncount() and print the size of the 1ist returned
184 c a l the method radiobuttoncount() and
7 print the si1ze of the 1 i s t returned
185 c a l l the method
1inkCount) and print the size of the 1ist returned
186
197
Activate VNindoy-
198
Go to semngs to actm
199
206