Professional Documents
Culture Documents
//at first this IT didnt run fully , i thought the code is not working
but ...
//i understood that if any error occurs ..it will stop there and will
not go to next line of the code ..
//so it didnt exeute the next line ofthe code.
1.If we want to point out span ..we have to point the parent too .
Try and catch …if any error occurred …it will catch the error and proceed with next steps .
Refer Logindaily.js
waitforExist()- checks if the element is present in the DOM even if the element is not visible in the
webpage.
waitUntil()-
//It sees whther the text is === given text ....if its not ...it will
wait for given time(15000) and
// will throw out an error saying the timed out ..the text didnt
appear.
return (await Loading.getText())==='LOADING COMPLETE.'},{
timeout:15000,
timeoutMsg:'timed out123'
})
Here it take more than 10,000 ms to get the required text ….so timeout is necessary.
waitForDisplay() isDisplayed()
Its an asynchronous Boolean function..it checks It is a synchronous Boolean fuction . It checks
repeatedly for the element whether it is immediately .It returns true ..if the element is
displayed for a specified time and returns an present and returns false if the element is not
error if it is not displayed. there.
ef
3.Addvalue() = goes on adding the value without clearing
await FirstName.addValue('Hello')
await browser.pause(5000)
await FirstName.addValue('Hi')
await browser.pause(5000)
await FirstName.setValue('How are you!')
await browser.pause(5000)
await FirstName.clearValue()
await browser.pause(5000)
SetValue() = it will first clear the previous entries and then inserts the value.
await expect(dropdown).toHaveValueContaining('java123')
b.toEqual()= Boolean fucntion
await expect(radio1_isDisplayed).toEqual(true)
5. Dropdown:
We can select by
a. Attribute
b. Index
c. C.Visible text.
Here Ignorecase mean to ignore the casesensitive …we have searched ‘CSS’ and expecting
‘css’ …which is not same in JS …but when ignorecase is used case sensitive is ignored.
d. const dropdown = await $('#dropdowm-menu-1')
e. await dropdown.selectByAttribute('value','java');
f. await expect(dropdown).toHaveValueContaining('java123')
g. browser.pause(200000)
h. const dropdown2= await $('#dropdowm-menu-2')
i. await dropdown2.selectByIndex(3)
j. await expect(dropdown2).toHaveValueContaining('jUnit',
{ignoreCase:true})
k. await browser.pause(2000)
l. const dropdown3= await $('#dropdowm-menu-3')
ef
m. await dropdown3.selectByVisibleText('CSS')
n. await browser.pause(2000)
o. await expect(dropdown3).toHaveValueContaining('css',
{ignoreCase:true})
p. await browser.pause(2000)
6.Actions
a. dragAndDrop
b.doubleClick()
c.hover= moveTo()
await browser.url('https://www.webdriveruniversity.com/Actions/index.html')
const drag = await $('#draggable')
const targetto= await $ ('#droppable')
await drag.dragAndDrop(targetto)
//dragAndDrop is a function ..which is used to drag the particular
element and drop it in the target .
await browser.pause(4000)
//2.
const doubleclick1 = await $('#double-click')
await doubleclick1.doubleClick();
await hover.moveTo()
ef
9.Alert –read this important.
In contrast, the toEqual() method is used to compare two string values, which
makes it suitable for comparing the expected and actual alert text.
10.Alert –
a. acceptAlert()
b. dismissAlert()
c. c.getAlerttext()- will return a string.
await (await $
('#myFile')).addValue('C:/Users/swetha.senthilkumar/Desktop/Webdriverio-
framework - Practise/test/specs/Data/dummay_fileUpload.txt')
11. browser.execute { }
This is in my case ..used for force click on locator…which is not actually a button.
Inorder to change the backgroundcolor of the page..it is impossible using normal wdio
commands ..so we use browser.execute
If the class is ”d-none”, then the contents of the class will be hidden ., so we cannot get the text
of that locator using getText.
ef
So I used the ‘id’ to locate .Then Parsed (converts str to obj) ….JSON.parse(str)
// MachinReportOEECheck.js
suites :{
smoke :['test/specs/Data/MachineStatusAPI.js',
'test/specs/Data/wait-command.js',
'test/specs/Data/add-items-to-basket.js'
],
example :[ 'test/specs/Data/wait-command.js',
'test/specs/Data/add-items-to-basket.js']
},//npx wdio --suite smoke
//it is used to run files from different folder .
//where as , npx wdio --spec location (either single file or folder)
Package.json..enter script :
Allure reports.
ef
6. Open in Browser using “: allure open(The reports will be generated in the browser)
May 15,2023
Val()= is used to get the current value and also set the value[its jQuery]
Date.val()
Then Date.val(‘2023-05-18’)
//This sets the given date in the date textbox ..but is not updated in the
DatetimePicker .
Here the event listener is dp.change…It is triggered when the date has to be
changed.
$('#inputDate').val(date).trigger('dp.change');
getValue.
June 1 , 2023
ef
JS- Math.random() will generate the numbers bet 0 & 1 …but not 1 .
ef