Wednesday, January 4, 2023

Karate Sample code with accepting cookies button in shadow dom

 


Feature: Login Test
This is Login Test

Scenario: Login with valid login credential testing

Given driver 'https://gpconnect.qa.stonex.com/'
#Given driver 'https://fxonline-demo.stonex.com/'
# we can inspect the page and get the locators in different variations like xPath:
# (don't forget to re-arrange the locator's quotes: double outside, single inside)
* delay(9000)
And input("//input[@name='identifier']","muraligandham437@gmail.com")
* delay(9000)
When click("//input[@value='Next']")
* delay(9000)
And input("//input[@id='input53']","Welcometostonex2029!")
When click("//input[@value='Verify']")
* delay(9000)
* delay(9000)

And script("#cmpwrapper", "_.shadowRoot.querySelector('#cmpbntyestxt').click()")


* delay(9000)
* delay(9000)

# retrieve the ShadowRoot of an element
#* def shadowRoot = driver.executeScript("return arguments[0].host", '#cmpwrapper')

# retrieve an element inside the ShadowRoot
# * def shadowElement = driver.executeScript("return arguments[0].querySelector('#cmpwelcomebtnyes')", shadowRoot)

# interact with the element
# * driver.click(shadowElement)


And script("#cmpwrapper", "_.shadowRoot.querySelector('#cmpbntyestxt').click()

* driver.maximize()
And input("//input[@id='companyLogin']","SFG_BA")
And input("//input[@id='userName']","sfgapprover")
And input("//input[@id='password']","Ndsb$1234")
# action
When click("//span[normalize-space()='Login']")
# We need to verify: For example webpage we logged in:
Then match driver.title == "StoneX | FXOnline"
* delay(9000)
And match
driver.url == 'https://fxonline-demo.stonex.com/Dashboard'

No comments:

Post a Comment