Hi,
Just need some assistance.
When an object is present on a webpage but not visible (as in you need to scroll down to see it), does katalon fail in this regard by default?
For some reason i thought katalon worked with the DOM???
Hi,
Just need some assistance.
When an object is present on a webpage but not visible (as in you need to scroll down to see it), does katalon fail in this regard by default?
For some reason i thought katalon worked with the DOM???
If theres an element on a page but maybe not in view, just doing the click action should scroll for you, what issues are you running into to? share any error logs etc.
Hi @hpulsford,
I asked the question just as a general question in terms of how objects are interacted with.
If you look at the below screen shots, I am trying to get the text value from a label. The label is present but not visible as you need to scroll down to see the label.
Scenario 1:
Now, when execute the getText method and the object is visible by executing the scroll, I get a value back (See screen shot and debug viewer value for the footerText variable).
When I execute the getText method and the object is not visible and i do not execute the scroll to method, I get a blank value.
Scenario 2:
When a checkbox is present and not visible, I get an exception that the object is not interactable.
When the checkbox is present and visible, all seems well.
Same thing happened to other controls as well
Create a custom keyword/package that does something like:
package com.my_company
public class utils {
/**
* @param selector (String) A DOM/CSS selector (not an XPath)
*/
static void scrollIntoView(String selector) {
String js = "document.querySelector('" + selector + "').scrollIntoView(true);"
WebUI.executeJavaScript(js, null);
}
}
In your test case, call it like this:
import static com.my_company.utils.*
...
scrollIntoView("#my_checkbox_id")
def static void scrollIntoView(TestObject to) {
String path = to.getSelectorCollection().get(SelectorMethod.CSS)
println path
String js = "document.querySelector(" + path + ").scrollIntoView(true);"
println js
WebUI.executeJavaScript(js, null);
}
i user a testpbject
test obejct css: button.mainly.jq-order-approve
when i run always say ,Unable to execute JavaScript
javascript error: button is not defined
(Session info: chrome=76.0.3809.87)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘CNCDUW0218’, ip: ‘172.17.103.139’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 76.0.3809.87, chrome: {chromedriverVersion: 76.0.3809.68 (420c9498db8ce…, userDataDir: C:\Users\cecichen\AppData\L…}, goog:chromeOptions: {debuggerAddress: localhost:57369}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: f87077d75d9d18e625a8ef43e84f3961
Yes I prefer waiting for an element to be visible than waiting an element to be present as you said. And yes
you can use also scrollToElement method before interacting with that element.
The CSS is fine if it carries the same classes as are present in the HTML document. A quick trip to the browser console to check it would prove that.
The error says the JS is broken - and it is - you (and I) missed the inner quotes:
String js = 'document.querySelector("' + path + '").scrollIntoView(true);'
Or, instead:
String path = '"' + to.getSelectorCollection().get(SelectorMethod.CSS) + '"'
i’s work now.
can you help this issue