Closed carlhabib closed 1 year ago
Your element locator looks correct. One thing you might want to try is open up Chrome, open the Console tab in the Developer Tools and run the $$
function to test your selector (more details here):
$$("input[aria-label='Select Record 2,387,701']")
Some reasons I can think of for this not working are:
After trying this: $$("input[aria-label='Select Record 2,387,701']")
I got the following:
Array [ input.ebx_checkboxCustom
]
0: <input class="ebx_checkboxCustom" type="checkbox" aria-label="Select Record 2,387,701">
accept: ""
accessKey: ""
accessKeyLabel: ""
align: ""
alt: ""
assignedSlot: null
attributes: NamedNodeMap(3) [ type="checkbox", aria-label="Select Record 2,387,701", class="ebx_checkboxCustom" ]
autocapitalize: ""
autocomplete: ""
autofocus: false
baseURI: redacted for privacy
checked: false
childElementCount: 0
childNodes: NodeList []
children: HTMLCollection { length: 0 }
classList: DOMTokenList [ "ebx_checkboxCustom" ]
className: "ebx_checkboxCustom"
clientHeight: 10
clientLeft: 2
clientTop: 2
clientWidth: 10
contentEditable: "inherit"
dataset: DOMStringMap(0)
defaultChecked: false
defaultValue: ""
dir: ""
disabled: false
draggable: false
enterKeyHint: ""
files: null
firstChild: null
firstElementChild: null
form: null
formAction: redacted for privacy
formEnctype: ""
formMethod: ""
formNoValidate: false
formTarget: ""
height: 0
hidden: false
id: ""
indeterminate: false
inert: false
innerHTML: ""
innerText: ""
inputMode: ""
isConnected: true
isContentEditable: false
labels: NodeList [ label.ebx_CheckboxButton_Label.ebx_emptyLabel
]
lang: ""
lastChild: null
lastElementChild: null
list: null
localName: "input"
max: ""
maxLength: -1
min: ""
minLength: -1
multiple: false
name: ""
namespaceURI: "http://www.w3.org/1999/xhtml"
nextElementSibling: <i class="ebx_checkboxDisplay" aria-hidden="true">
nextSibling: <i class="ebx_checkboxDisplay" aria-hidden="true">
nodeName: "INPUT"
nodeType: 1
nodeValue: null
nonce: ""
offsetHeight: 13
offsetLeft: 9
offsetParent: <td class="ebx_tvSelectCell" style="width: 31px;">
offsetTop: 6
offsetWidth: 13
onabort: null
onanimationcancel: null
onanimationend: null
onanimationiteration: null
onanimationstart: null
onauxclick: null
onbeforeinput: null
onblur: null
oncanplay: null
oncanplaythrough: null
onchange: null
onclick: null
onclose: null
oncontextmenu: null
oncopy: null
oncuechange: null
oncut: null
ondblclick: null
ondrag: null
ondragend: null
ondragenter: null
ondragexit: null
ondragleave: null
ondragover: null
ondragstart: null
ondrop: null
ondurationchange: null
onemptied: null
onended: null
onerror: null
onfocus: null
onformdata: null
onfullscreenchange: null
onfullscreenerror: null
ongotpointercapture: null
oninput: null
oninvalid: null
onkeydown: null
onkeypress: null
onkeyup: null
onload: null
onloadeddata: null
onloadedmetadata: null
onloadstart: null
onlostpointercapture: null
onmousedown: null
onmouseenter: null
onmouseleave: null
onmousemove: null
onmouseout: null
onmouseover: null
onmouseup: null
onmozfullscreenchange: null
onmozfullscreenerror: null
onpaste: null
onpause: null
onplay: null
onplaying: null
onpointercancel: null
onpointerdown: null
onpointerenter: null
onpointerleave: null
onpointermove: null
onpointerout: null
onpointerover: null
onpointerup: null
onprogress: null
onratechange: null
onreset: null
onresize: null
onscroll: null
onscrollend: null
onsecuritypolicyviolation: null
onseeked: null
onseeking: null
onselect: null
onselectionchange: null
onselectstart: null
onslotchange: null
onstalled: null
onsubmit: null
onsuspend: null
ontimeupdate: null
ontoggle: null
ontransitioncancel: null
ontransitionend: null
ontransitionrun: null
ontransitionstart: null
onvolumechange: null
onwaiting: null
onwebkitanimationend: null
onwebkitanimationiteration: null
onwebkitanimationstart: null
onwebkittransitionend: null
onwheel: null
outerHTML: '<input type="checkbox" aria-label="Select Record 2,387,701" class="ebx_checkboxCustom">'
outerText: ""
ownerDocument: HTMLDocument redacted for privacy
parentElement: <label class="ebx_CheckboxButton_Label ebx_emptyLabel" title="Select Record 2,387,701">
parentNode: <label class="ebx_CheckboxButton_Label ebx_emptyLabel" title="Select Record 2,387,701">
part: DOMTokenList []
pattern: ""
placeholder: ""
prefix: null
previousElementSibling: null
previousSibling: null
readOnly: false
required: false
scrollHeight: 10
scrollLeft: 0
scrollLeftMax: 0
scrollTop: 0
scrollTopMax: 0
scrollWidth: 10
selectionDirection: null
selectionEnd: null
selectionStart: null
shadowRoot: null
size: 20
slot: ""
spellcheck: false
src: ""
step: ""
style: CSS2Properties(0)
tabIndex: 0
tagName: "INPUT"
textContent: ""
textLength: 2
title: ""
translate: true
type: "checkbox"
useMap: ""
validationMessage: ""
validity: ValidityState { valueMissing: false, typeMismatch: false, patternMismatch: false, … }
value: "on"
valueAsDate: null
valueAsNumber: NaN
webkitEntries: Array []
webkitdirectory: false
width: 0
willValidate: true
<prototype>: HTMLInputElementPrototype { stepUp: stepUp(), stepDown: stepDown(), checkValidity: checkValidity(), … }
length: 1
I tried the intuitive but obviously wrong solution of locating it as the following:
locator: {css: "input[aria-label='Select Record 2,387,701']"}
But it still doesn't work
@carlhabib try this https://getopentest.org/reference/selenium-keywords.html#assertelementselected
@carlhabib
and maybe you need try use xpath (rmb on element code block -> copy -> copy xpath)
and how adrianth says, you try select element from wrong context
You can view current context used by this issue: https://github.com/mcdcorp/opentest/issues/616#issuecomment-1514454458
Verify, that he has same name that name in your browser
(if this work $$("input[aria-label='Select Record 2,387,701']")
and name of context diffferents beetwen your browser and opentest - you are inside wrond context)
I tried with the xpath and got the same error however After following the steps of #616 and running:
args:
script: |
return window.frames.name;
I got the following: 13:21:30 | ACTOR1 | Executing action org.getopentest.base.ScriptAction (no arguments were provided)... 13:21:30 | ACTOR1 | The frame name is
While in the browser for:
window.frames.name
I got
"ebx-legacy-frame_0"
When i tried to run:
args:
script: |
return window.frames[0].name;
I got:
ERROR: java.lang.Exception: Failed executing test web, segment 1
at org.getopentest.base.TestActor.executeTestSegment(TestActor.java:2208)
at org.getopentest.base.TestActor.runOneSession(TestActor.java:3077)
at org.getopentest.base.TestActor.runOneSession(TestActor.java:3113)
at org.getopentest.Main.main(Main.java:20)
Caused by: java.lang.RuntimeException: There was an error while executing action no. 9 (org.getopentest.selenium.ExecuteScript) in segment 1 of test web.
The action definition was:
{
"action": "org.getopentest.selenium.ExecuteScript",
"args": {
"script": "return window.frames[0].name;\n"
}
}
at org.getopentest.base.TestActor.executeTestSegment(TestActor.java:2142)
... 3 more
Caused by: java.lang.RuntimeException: Failed executing action org.getopentest.selenium.ExecuteScript with arguments {"script":"return window.frames[0].name;\n"}
at org.getopentest.base.TestActor.executeActionByDef(TestActor.java:1872)
at org.getopentest.base.TestActor.executeTestSegment(TestActor.java:2092)
... 3 more
Caused by: java.lang.RuntimeException: org.openqa.selenium.JavascriptException: javascript error: Cannot read properties of undefined (reading 'name')
So basically what needs to happen is to set the frame in opentest to "ebx-legacy-frame_0"? Or is there something i'm missing?
@carlhabib i think you are inside wrong context this is normal, that actor's command return nothing, your default context can have not name
maybe it is help you https://youtu.be/kRdTMTQXXfU?t=1131 in this case you can see how to switch context
documentation this: https://getopentest.org/reference/selenium-keywords.html#switchtoframe
So basically what needs to happen is to set the frame in opentest to "ebx-legacy-frame_0"? Or is there something i'm missing?
Yes, i think this correct way
also you can saw all you frames inside console tab:
It worked. I changed to the correct iframe and everything worked thank you very much @Keonik1 and @adrianth
I am using OpenTest Build: 1.3.8 Feb 25, 18:58 Commit: 50659ecda06a
I am trying to select the following element
<input type="checkbox" aria-label="Select Record 2,387,701" class="ebx_checkboxCustom">
using the following action
but i am getting the following error in the log
I tried adding a delay before the action to make sure all the elements loaded and tried using its parent element as a locator since "Select Record 2,387,701" is the unique identifier for the locator
<label class="ebx_CheckboxButton_Label ebx_emptyLabel" title="Select Record 2,387,701"><input type="checkbox" aria-label="Select Record 2,387,701" class="ebx_checkboxCustom"><i class="ebx_checkboxDisplay" aria-hidden="true"> </i></label>
but i got the same error