Can't click on element (overlay)

I’m trying to automate a file upload. The upload itself is working perfectly but clicking on the “already existing element” button on an overlay doesn’t work.

I tryed the “spy web” function and the xpaths given by chrome and firefox.
Also a javaScript Keyword I found in another comment in this forum.

Greetings

The code:

// Create random string for the file
public String generateString(Random random, String characters, int length) {
char text = new char[length];
for (int i = 0; i < length; i++) {
text[i] = characters.charAt(random.nextInt(characters.length()));
}
return new String(text);
}

int i = 0

for (i = 0; i < 1; i++) {

WebUI.openBrowser('')

WebUI.navigateToUrl('http://143.93.44.22:8085/index.php/login')

WebUI.setText(findTestObject('Object Repository/Page_ownCloud/input_ownCloud_user'), 'admin')

WebUI.setEncryptedText(findTestObject('Object Repository/Page_ownCloud/input_Benutzername oder E-Mail_password'), 'RAIVpflpDOg=')

WebUI.click(findTestObject('Object Repository/Page_ownCloud/input_Passwort_submit'))

Thread.sleep(2500)

WebUI.click(findTestObject('Object Repository/Page_Dateien - ownCloud/span_ber WebDAV auf Ihre Dateien zuzugreifen_icon icon-add'))

Thread.sleep(2500)

// Path to docs
String path = String.format('C:\\Users\\s13bfe\\Downloads\\testdocs\\%d.txt', i)

CustomKeywords.'aPackage.Upload.uploadFile'(findTestObject('Object Repository/Page_Dateien - ownCloud/span_Hochladen'),	path)

Thread.sleep(2000)

//Tried this
WebUI.click(findTestObject('Object Repository/Page_Dateien -ownCloud/Object Repository/Page_Dateien - ownCloud/label_Bereits existierende Dateien'))

// And this
CustomKeywords.'aPackage.clickReplace.clickUsingJS'(findTestObject('Object Repository/Page_Dateien -ownCloud/label_Bereits existierende Dateien'),	10)

//Thread.sleep(2500)
//
//WebUI.click(findTestObject('Object Repository/Page_Dateien -ownCloud/button_Fortsetzen'))

WebUI.closeBrowser('')

}

The Keyword:

@Keyword
def clickUsingJS(TestObject to, int timeout) {
	WebDriver driver = DriverFactory.getWebDriver()
	WebElement element = WebUiCommonHelper.findWebElement(to, timeout)
	JavascriptExecutor executor = ((driver) as JavascriptExecutor)
	executor.executeScript('arguments[0].click()', element)
}

HTML of the element:

<label for="checkbox-allexistingfiles">Bereits existierende Dateien<span class="count"></span></label>

screen shots of the page itself and the html will help alot. A copy of your script would also be good to see.

1 Like

Updated the post.

I know you have the thread but maybe try this. Also what error are you getting with click? Could you share the full error log

WebUI.waitForElementVisible(findTestObject('Object Repository/Page_Dateien -ownCloud/label_Bereits existierende Dateien'), 10)
WebUI.click(findTestObject('Object Repository/Page_Dateien - ownCloud/label_Bereits existierende Dateien'))

That didn’t work either.

whats the error ?

This one:

07-01-2019 04:00:50 PM waitForElementVisible(findTestObject("Object Repository/Page_Dateien -ownCloud/label_Bereits existierende Dateien"), 10)

Elapsed time: 0,084s

Unable to wait for object to be visible (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to wait for object to be visible
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
	at com.kms.katalon.core.webui.keyword.builtin.WaitForElementVisibleKeyword.waitForElementVisible(WaitForElementVisibleKeyword.groovy:99)
	at com.kms.katalon.core.webui.keyword.builtin.WaitForElementVisibleKeyword.execute(WaitForElementVisibleKeyword.groovy:68)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.waitForElementVisible(WebUiBuiltInKeywords.groovy:434)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$waitForElementVisible$4.call(Unknown Source)
	at Owncloud_PI.run(Owncloud_PI:81)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1561989632510.run(TempTestCase1561989632510.groovy:21)
Caused by: java.lang.IllegalArgumentException: Object is null
	at com.kms.katalon.core.helper.KeywordHelper.checkTestObjectParameter(KeywordHelper.java:33)
	at com.kms.katalon.core.webui.keyword.builtin.WaitForElementVisibleKeyword$_waitForElementVisible_closure1.doCall(WaitForElementVisibleKeyword.groovy:76)
	at com.kms.katalon.core.webui.keyword.builtin.WaitForElementVisibleKeyword$_waitForElementVisible_closure1.call(WaitForElementVisibleKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.WaitForElementVisibleKeyword.waitForElementVisible(WaitForElementVisibleKeyword.groovy:99)
	at com.kms.katalon.core.webui.keyword.builtin.WaitForElementVisibleKeyword.execute(WaitForElementVisibleKeyword.groovy:68)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.waitForElementVisible(WebUiBuiltInKeywords.groovy:434)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$waitForElementVisible$4.call(Unknown Source)
	at Script1561981064146.run(Script1561981064146.groovy:81)
	... 11 more
)

So this tells me that the location of the object has changed? have you moved this object at all. Because its struggling to locate it. Also, im no expert at html but are you sure you have captured the actuall checkbox and not the label next to it.

This looks like the html for the label next to the actual box. If you right click on the box and inspect, whats the html.

What exactly do you mean by “moved the object”?
It’s still in the same repository if you mean that.

When clicking on the label manually the checkbox is checked too.
Also tried just to grab the checkbox.

If your in manual mode(not script mode) and double click on the object, does the path to the object appear?

I can choose the element.

If I’m double clicking the following appears:

Yea so thats why its null, you’ve changed something to do with the location of the object and it cant locate it. Go into your object repository and drag the object from there into the the object placement in manual mode. (Sorry if it doesnt make much sense, hard to explain)

Like this but with the label_Bereits existierende Dateien for both click step and wait for step

2 Likes

This fixed it! Thank you very much for your patience and good explanation!
Have a nice day. :slight_smile:

1 Like

Glad you got it working, If you could mark the awnser as the solution would be even better :slight_smile:

1 Like