Chrome Headless Browser Issue

Hi Team.
The Chrome Headless browser was unable to identify the element even it is mentioned with id in the test case. While running the same test case in chrome browser it was working perfectly fine and was failing when I try to run the test case using Chrome Headless Browser.

Unable to find the element located by ‘By.xpath: //input[@id = ‘tipo_meta-display_name’]’. Please recheck the objects properties to make sure the desired element is located.

Can anyone help me with the issue.

@srianoop.d one common issue for test failing in headless mode is due to different window size compared with the plain (gui) mode.
please try to run your tests in windowed mode choosing various sizes and see if you can reproduce it, sometime elements ‘not visible’ are not rendered.

1 Like

Thanks for your response @Ibus . I tried setting up same window size in chrome browser and chrome headless browser but in normal chrome browser it was working perfectly fine but when it comes to chrome headless browser it was throwing the error that it was unable to find the element in headless browser.

Unable to find the element located by ‘By.xpath: //*[@id=“tipoForm”]/div/div[3]/div/section/div/div/section/div/div/table/tbody/tr/td[4]/div/button[1]’. Please recheck the objects properties to make sure the desired element is located.

Is there anything i was missing while running the chrome headless browser test cases!!

Unable to find the element located by ‘By.xpath: //*[@id=“tipoForm”]/div/div[3]/div/section/div/div/section/div/div/table/tbody/tr/td[4]/div/button[1]

Will the Chrome Headless browser capable of identifying elements that had Div tags in its Xpath along with its ID??

I was running a test case in the Normal chrome browser and is working fine but when it comes to Headless browser it was unable to find that element. I have also set the Window size the same as in the normal Chrome browser but still facing the error.
Is there anything to be added for the Headless browser to make the test case execution successful!!
Thanks.

@srianoop.d Try

WebUI.setViewPortSize(1360, 978)

There seems to be an issue with the xpath you are trying, It looks like Absolute xpath type but generated by Katalon Recorder ? Can you share the HTML of element giving problem ?

1 Like

Hi @manpreet.mukkar I tried setting the port size 1360,978 as you suggested but the results were same.

Unable to find the element located by ‘By.xpath: //*[@id=“tipoForm”]/div/div[2]/div/section/div/div/section/div/div/table/tbody/tr[2]/td[5]/div/button[3]’. Please recheck the objects properties to make sure the desired element is located.
i was getting the same error.

The HTML of that element is
" /html/body/tp-root/tp-layout/div/mat-sidenav-container/mat-sidenav-content/div/tp-module-loader/tp-tiporole/div[1]/form/div/div[2]/div/section/div/div/section/div/div/table/tbody/tr[2]/td[5]/div/button[3] "

Anyone have a solution as i’m encountering same problem!

Hi @Ziyaad i tried using 1880*990 and it worked for me.

I am having the same issue (I am working on katalon version 7.3.1) , Test script is running fine in chrome browser but failing in Chrome headless.

Xpath is //div[@id=‘Accounts’]/a[4].

Try setting up a different port size … Like in my case i have used 1880*990 and it worked for me.

I tried setting that in the login test case but it did not solve my problem.

Test case is about adding a category and verify its added and then deleted the added category.
It works fine if I run the script in chrome browser but it fails if executed in headless chrome.
In headless script is failing as below (i am using katalon 7.3.1)

WebUI.click(findTestObject(‘Products/Add Category to a product/span_Type Category’))

println(“$NewCategory”)

WebUI.setText(findTestObject(‘Products/Add Category to a product/Search Category’), NewCategory)

WebUI.sendKeys(findTestObject(‘Products/Add Category to a product/Search Category’), Keys.chord(Keys.ENTER))

WebUI.waitForElementClickable(findTestObject(‘Products/Add Category to a product/button_Add category’), 20)

WebUI.click(findTestObject(‘Products/Add Category to a product/button_Add category’))
//WebUI.delay(5)

String AddedCategory = WebUI.getText(findTestObject(‘Products/Add Category to a product/Heading of new category’))

println(“$AddedCategory”)

if (AddedCategory == NewCategory)
{

WebUI.verifyElementPresent(findTestObject('Products/Add Category to a product/a_Remove'), 5)

WebUI.click(findTestObject('Products/Add Category to a product/a_Remove'))

WebUI.verifyAlertPresent(5)

WebUI.acceptAlert()

} else
{
assert false
}

I am also facing the same issue

Hi @sunil.saptal,

As @Ibus said, this issue is usually due to different window sizes. You could resize the browser window with WebUI.setViewportSize(<width>, <height>).

you can check if it really is a window size issue by checking the screenshot at that time.

String screenshotLocation = WebUI.takeScreenshot()
println screenshotLocation
2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.