Getting Element not visible exception error

Hi,
I am trying to click on web element by writing manually test case .All the time error is appearing :((Root cause: org.openqa.selenium.ElementNotVisibleException: element not visible).

I have tried using keyword Wait for element visible and wait for element clickable, but no luck.

Please advide.

Iā€™ve run into pages like this you will want to use the javascript click object keyword. I also found this extremely frustrating.

Create this keyword and try to use this, hopefully this works for you.

package customKeywordsFromKatalon

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.annotation.Keyword

import com.kms.katalon.core.checkpoint.Checkpoint

import com.kms.katalon.core.checkpoint.CheckpointFactory

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords

import com.kms.katalon.core.model.FailureHandling

import com.kms.katalon.core.testcase.TestCase

import com.kms.katalon.core.testcase.TestCaseFactory

import com.kms.katalon.core.testdata.TestData

import com.kms.katalon.core.testdata.TestDataFactory

import com.kms.katalon.core.testobject.ObjectRepository

import com.kms.katalon.core.testobject.TestObject

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords

import internal.GlobalVariable

import MobileBuiltInKeywords as Mobile

import WSBuiltInKeywords as WS

import WebUiBuiltInKeywords as WebUI

import org.openqa.selenium.WebDriver as WebDriver

import org.openqa.selenium.WebElement as WebElement

import org.openqa.selenium.interactions.Actions as Actions

import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebUiCommonHelper

import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

import org.openqa.selenium.JavascriptExecutor as JavascriptExecutor

public class JavascriptClick {

@Keyword

def clickUsingJS(TestObject to)

{

WebDriver driver = DriverFactory.getWebDriver()

WebElement element = WebUiCommonHelper.findWebElement(to, 30)

JavascriptExecutor executor = ((driver) as JavascriptExecutor)

executor.executeScript(ā€˜arguments[0].click()ā€™, element)

}

}

2 Likes

+1 for the javascript clickā€¦ it worksā€¦
after insane attempts to get the button recognised as visible:

dynamicObject = findTestObject('Page_Add_new_product/input_publish')
WebUI.scrollToElement(dynamicObject, 3)
WebUI.waitForElementClickable(dynamicObject, 3)
WebUI.click(dynamicObject)  //still doesn't work

The javascript click does it:

CustomKeywords.'customKeywordsFromKatalon.JavascriptClick.clickUsingJS'(dynamicObject)

ā€¦ should be available as standard

2 Likes

Greeting, Iā€™m having a hard time understanding the javascript click object keyword. Since Iā€™m also facing the same problem with ā€™ org.openqa.selenium.ElementNotVisibleException: element not visibleā€™. Can someone explain how and where I can use the javascript to to solve the issues?

yes @Mohammad Shahiran there is a folder to the far left under test suites, and all that called ā€œkeywordsā€ you have to create a new package and a new keyword like above. then in your test case when you choose keyword from the drop down or copy and past like what jonathan has you can call the keyword to do your click. make sense? if not I can add screenshots.

I understand. Thank you very much.