Element not interactable issue when SetText

Hello, I know that I already have a thread regarding this Element not interactable issue, since my previous thread is already closed (Element is not interactable issue), so I need to create another one.

I have a text field to input an address in the Address Line 2 field, and this is the XPath of the address object

This is the code that I used to set a value in the Address Line 2 text field.

When the Address Line 2 code is executed, I encountered Element not interactable. I followed the advice on another thread to input a delay, but still no luck.

Hope can someone share any reference where I can resolve my issue. Thank you!

How about trying the below xpath for your element instead of what you have and see if that finds it?

//div[text()="Address line 2"]/preceding-sibling::input

What this does is goes from the “Address line 2” text and then moves up to its sibling (tag at the same level).

Note: I generally use the form, /../ to move up to a parent of the element, similar to /parent::, whereas you seem to want the div element’s sibling.

Hi @escalryan,

This could work too:
//*[@class = 'q-field__label no-pointer-events absolute ellipsis']
If elements are NOT unique you can use:
(//*[@class = 'q-field__label no-pointer-events absolute ellipsis'])[1] //for 1st
(//*[@class = 'q-field__label no-pointer-events absolute ellipsis'])[2] //for 2nd
You could also use contains:
//*[contains(@class, 'no-pointer-events absolute ellipsis')]
If elements are NOT unique you can use:
(//*[contains(@class, 'no-pointer-events absolute ellipsis')])[1]
(//*[contains(@class, 'no-pointer-events absolute ellipsis')])[2]
(//*[contains(@class, 'no-pointer-events absolute ellipsis')])[3] ...

Hi @grylion54 already used the XPath that you’re provided, and still the element not interactable.

Can I then suggest to ensure that the textbox is within the viewport?

WebElement webItem = WebUI.findWebElement(findTestObject('Patient Info/txtAddressL2'))

WebUI.scrollToPosition(100, webItem.getLocation().getY())

WebUI.waitForElementVisible(findTestObject('Patient Info/txtAddressL2'), 20)
WebUI.setText(findTestObject('Patient Info/txtAddressL2'), "Address Line 2 Automation Address")

Do you have your web page at full screen (WebUI.maximizeWindow())?

Also, can I ask why you did not put any address for Address1? You may need to have something there in order to use Address2. Just something to try. Easy enough to see if you do it manually (without KS) and see if your page lets you just enter something in Address2 without something in Address1.

Hi @grylion54 I’ve asked our developer to make some changes to the HTML of the object and now I am not getting the Element not interactable already, May I ask how I can set a value to the object using the queryselector? I used the code below, but the “Testing” value overlapped with the object instead of inserting it inside the textbox.

hi @grylion54 problem solved thank you!

I used code below.

Should you need it, here is another way that it can be done. I also put in a verification that the text was entered correctly.

WebUI.setText(findTestObject('Patient Info/ddlAddressL1'), '1010')
WebUI.verifyElementAttributeValue(findTestObject('Patient Info/ddlAddressL1'), 'value', '1010', 10)

WebUI.setText(findTestObject('Patient Info/txtAddressL2'), 'Testing Automation Address Line 2')
WebUI.verifyElementAttributeValue(findTestObject('Patient Info/txtAddressL2'), 'value', 'Testing Automation Address Line 2', 10)

You can use “sendKeys” instead of setText. They do the same thing.

1 Like