Happens, don’t beat yourself up.
Where? What CSS?
Happenstance. It may not be the same on his next <select><option>...
fragment. It’s better (safer?) to go with his stated need in this case, verify the contained text .
Aside: I believe (can’t be bothered to go look it up) the option.text
property will contain a copy of the innerText. But either way, the option.value
property is what is sent to the server over HTTP when the form is submitted.
Aside2: Not sure why he hasn’t tried my JS. It’ll work right off the bat (typos willing).
1 Like
Hi @Peter_Wilson ,
That’s the only element in the list
Thanks,
Ruben B
Hi @Russ_Thomas ,
I have missed your previous reply. I have tried using your JS (innerText, text, value), please find below the results.
Thanks,
Ruben B
It’s difficult to tell you what you did wrong because you didn’t share your code. If you use the code I gave you, it will work.
And @jpereyra , please pay attention to this:
And this:
That’s two of us saying the same thing. You’re posting a very limited section of code - we need to see your code in its surrounding context. Post your Groovy code and your JS code.
Thanks.
Hi @Russ_Thomas ,
Thanks for the info and your patience, PFB below the script.
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
WebUI.openBrowser(’’)
WebUI.navigateToUrl(‘https://company.site.com/saml_login?ReturnTo=https%3A//insider.illumina.com/’)
WebUI.setText(findTestObject(‘Page_company - Sign In/input_Username_username’), ‘jpereyra’)
WebUI.setEncryptedText(findTestObject(‘Page_company - Sign In/input_Password_password’), ‘IxeH2LO7Fyi3mwGtluhdRg==’)
WebUI.click(findTestObject(‘Page_company - Sign In/input_Remember me_okta-signin-submit’))
WebUI.scrollToElement(findTestObject(‘Page_Home page Insider/div_Holidays Section Home Page’), 0)
WebUI.verifyElementPresent(findTestObject(‘Object Repository/Page_Home page Insider/div_Holidays Section Home Page’), 0)
WebUI.verifyElementVisible(findTestObject(‘Page_Home page Insider/div_Holidays Section Home Page’))
WebUI.click(findTestObject(‘Object Repository/Page_Home page Insider/span_Holidays’))
WebUI.verifyElementPresent(findTestObject(‘Object Repository/Page_Holiday Company Calendar Insider/div_Holidays Section Holidays page’),
0)
WebUI.verifyElementVisible(findTestObject(‘Page_Holiday Company Calendar Insider/div_Holidays Section Holidays page’))
String js = '''
var sel = document.querySelector("#edit-year");
return sel.options[sel.selectedIndex].innerText;
'''
WebUI.verifyElementPresent(findTestObject(‘Object Repository/Page_Holiday Company Calendar Insider/div_Next Holidays’),
0)
WebUI.verifyElementVisible(findTestObject(‘Page_Holiday Company Calendar Insider/div_Next Holidays’))
WebUI.closeBrowser()
Please let me know if I’m missing anything.
Thanks,
Ruben B
You missed a line. Here’s a copy of the original code I sent you. Look at the last line:
Now you need to use the Groovy text variable (circled above) to verify it has the correct value. For example,
println text
Ibus
October 4, 2019, 4:41pm
28
@jpereyra and pleaaaaase use code formatting when posting logs.
thank you!
@jpereyra I edited your last post to add ```
(three backticks) around your code. If you edit your post you can see what I did.
Please post code and logs like that - or @Ibus will drop his phone
2 Likes
Hi @Russ_Thomas ,
I think the code is right written now
WebUI.verifyElementVisible(findTestObject('Page_Holiday Company Calendar Insider/div_Holidays Section Holidays page'))
String js = '''
var sel = document.querySelector("#edit-year");
return sel.options[sel.selectedIndex].innerText;
'''
String text = WebUI.executeJavaScript(js, null)
printIn text
WebUI.verifyElementPresent(findTestObject('Page_Holiday Company Calendar Insider/div_Next Holidays'), 0)
below is the result
Thanks,
Ruben B
1 Like
Hi @Ibus ,
Sorry about that, i’m pretty new on this. It won’t happen again
Thanks,
Ruben B
2 Likes
The JavaScript code is using a reference to #edit-year
which is derived from your screenshot. When you run that js, the error seems to imply there is no element with that id.
All I can do now is refer you back to this:
Thanks All for the help provided to try to solve this. I’ll continue digging and I’ll let you know if I find a solution.
1 Like