Test case working fine on Chrome but not on Firefox

Hello Team,

I have a scenario in which I am trying to verify the flow of payments using different credit cards. The script I created is working fine on Chrome and doing all the validations but on Firefox it is not working and it gets stuck on one particular step. Its a button that takes user to the Credit Card Information page from the Shipping information page. Even on Chrome initially I was not able to click on that button using the built in Click keyword so I created a keyword ( ClickUsingJavaScript) based on the help I found here on forum and it worked fine on Chrome but it is not working for Firefox. The page where is button is present is Javascript.

Any help would be appreciated.

Here is the code for Keyword I am using to Click on button.

package clickusingjavascript

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.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW

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

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

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

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

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

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

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

import internal.GlobalVariable

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

@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)

}

Welcome to web testing, this is an age-old problem! :sweat_smile:

Building custom solutions that work across all web drivers is usually a fool’s errand, but it can be done in some instances. Can you share the error that you’re getting at this step when running in Firefox (if any), or describe the behavior when the test “gets stuck”?

Hello @Brandon_Hein

Below is the error, Basically on Firefox I can see it is not navigating to Billing information page and is stuck on Shipping method page.

But the error I am seeing is below, The error Katalon is mentioning over here belongs to next page which is Credit Card information page but when I am watching execution Firefox doesn’t even navigate to that page and is stuck on the page before which is Shipping method page.

I also want to mention that the Credit Card information page consists of bunch of iFrames, So I am switching to Iframe for CC Number Field to enter CC number then switching back to default content then again switching back to iFrame for Card Holder name and so on.

--------------- Error -------------

Test Cases/Payments Testing/US/Valid Visa FAILED.

Reason:

com.kms.katalon.core.exception.StepFailedException: Unable to verify image ‘Object Repository/Payments_Page/iframe_CC_number_field’ present (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Payments_Page/iframe_CC_number_field’ located by ‘By.xpath: (.//*[normalize-space(text()) and normalize-space(.)=‘Card number’])[1]/following::iframe[1]’ not found)

at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:27)

at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword.switchToFrame(SwitchToFrameKeyword.groovy:84)

at com.kms.katalon.core.webui.keyword.builtin.SwitchToFrameKeyword.execute(SwitchToFrameKeyword.groovy:68)

at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.switchToFrame(WebUiBuiltInKeywords.groovy:2869)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$switchToFrame$9.call(Unknown Source)

at Valid Visa.run(Valid Visa:87)

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:328)

at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)

at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)

at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)

at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)

at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)

at TempTestCase1548114310006.run(TempTestCase1548114310006.groovy:22)

Thanks! Ok so the error you are seeing is not being thrown from the step where you click the link on the Shipping information page, it’s failing later in the script because the click didn’t actually work. That’s good info, but also means this is a tricky problem because it’s failing silently.

I can make a couple suggestions, but I don’t use geckodriver very often (I pretty much only use chrome), so these are just suggestions:

1.) Try clicking on the element using the standard WebDriver approach and see if it works. If it does, you may need to use conditional logic to decide which method to click the link with.

2.) Open the inspector within Firefox and type the xpath into the console manually as follows: $x("//xpath//to//my//link"). Do the same thing in the Chrome inspector and look for differences. If there are differences, or the xpath works in one, and not the other, try making a more generic XPath you’re sure is identifying the same element in both browsers. Usually when a click() function does nothing, and throws no errors, it’s because a different element was located than was intended.

3.) Stick with chrome :upside_down_face:

Like I said, I rarely execute in Firefox, so maybe someone with more background with that driver can offer some other solutions/suggestion???

2 Likes

Thanks @Brandon_Hein for your solution, I will try to use the suggestions tomorrow. Even for us Firefox is not a blocker as team is happy with the test working on Chrome but I still wanted to make sure that I am not missing anything.

Thanks again.

Looks like the element (image) the script is trying to interact with is inside of an iframe. Did you remember to use WebUI.switchToFrame() in the previous step?

1 Like

Mr Firefox, here. :stuck_out_tongue:

The only issues I’ve noticed with geckodriver occur with checkboxes. For reasons I’ve never been able to fathom*, a jQuery click [ $(selector).click ] fails “often” where a vanilla JS click [document.querySelector(selector).click] works 100%.

*Pragmatism wins - I spent minimal time looking, tried qS, found it worked and moved on.

1 Like

Hello @Mate,

Yes I have used Switchtoframe keyword.Without it I wasn’t able to enter anything in the CC Number field.

Firefox is failing at this particular step, Chrome is not giving error and transactions are completing.

Is the Firefox failing with the same error message? If not, post the error message, we will be a step closer to the solution.

That is how you debug, btw. If our actions had consenquences, something changed when we added another command. So, anything that showed up after that is a useful piece of information.

1 Like

Hello @Mate_Mrse

I will try to post the error. I didn’t got chance to work on this yesterday.I hope today I will be working on this.

Thanks,

Hello @Mate_Mrse @Russ_Thomas @Brandon_Hein

This is very weird. I added a delay right before the step where the test case was failing in Firefox and it worked. I am under impression that it has something to do with my Custom keyword Clickwithjavascript. The reason why I am saying this is because I have another Test Case with the same issue and adding delay also worked there. I am happy now that its working but just wanted to let you guys know.

Now as my test case is able to make progress I am facing another issue :stuck_out_tongue: in which on Firefox the CCnumber feild is not getting input from Katalon properly. Getting only first four digits. I will try my best to fix it myself before starting another post.

I am attaching the script of that custom keyword in case you guys want to see.

package clickusingjavascript

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.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW

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

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

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

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

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

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

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

import internal.GlobalVariable

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

@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)

}

It is a good practice to add waits before interacting with a page after a page changes. Maybe just, for whatever reason, it took half a second longer for Firefox to render the element and that’s why the test failed. :man_shrugging:

2 Likes

@Mate_Mrse Thanks for your suggestion. I will keep your suggestion in mind while working on test.

Also I fixed the CCNumber issue but its again firefox thing.

Hi,

I am getting the same problem as me test case is working fine in chrome but is not working on firefox. I am getting the following error:
Can anybody suggest the solution

Test Cases/TestCase1 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to open browser with url: ‘’
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.OpenBrowserKeyword.openBrowser(OpenBrowserKeyword.groovy:81)
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword.execute(OpenBrowserKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.openBrowser(WebUiBuiltInKeywords.groovy:60)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$openBrowser.call(Unknown Source)
at TestCase1.run(TestCase1:16)
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 TempTestCase1561645065934.run(TempTestCase1561645065934.groovy:21)
Caused by: org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: WIN10
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘COB10L-PF0V6548’, ip: ‘172.29.6.203’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: driver.version: CGeckoDriver
at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:100)
at org.openqa.selenium.firefox.FirefoxOptions.getBinary(FirefoxOptions.java:216)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:187)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:147)
at com.kms.katalon.selenium.driver.CFirefoxDriver.(CFirefoxDriver.java:21)
at com.kms.katalon.core.webui.driver.firefox.CGeckoDriver.(CGeckoDriver.java:12)
at com.kms.katalon.core.webui.driver.firefox.CGeckoDriver.from(CGeckoDriver.java:17)
at com.kms.katalon.core.webui.driver.DriverFactory.createNewFirefoxDriver(DriverFactory.java:463)
at com.kms.katalon.core.webui.driver.DriverFactory.startNewBrowser(DriverFactory.java:237)
at com.kms.katalon.core.webui.driver.DriverFactory.openWebDriver(DriverFactory.java:191)
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.doCall(OpenBrowserKeyword.groovy:74)
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.call(OpenBrowserKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 17 more

Check your Firefox install.

I re-installed the firefox but not as an admin of the machine, just as a user. May be that can be the problem??
I am getting the following error while trying to execute on internet explorer.
Also the IE gets opened and a message “This is the initial start up page for web driver server” is diplayed.

Test Cases/TestCase1 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to open browser with url: ‘’
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.OpenBrowserKeyword.openBrowser(OpenBrowserKeyword.groovy:81)
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword.execute(OpenBrowserKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.openBrowser(WebUiBuiltInKeywords.groovy:60)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$openBrowser.call(Unknown Source)
at TestCase1.run(TestCase1:16)
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 TempTestCase1561647219865.run(TempTestCase1561647219865.groovy:21)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unexpected error launching Internet Explorer. Browser zoom level was set to 150%. It should be set to 100%
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘COB10L-PF0V6548’, ip: ‘172.30.89.176’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: driver.version: CInternetExplorerDriver
remote stacktrace:
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at com.kms.katalon.selenium.driver.CInternetExplorerDriver.execute(CInternetExplorerDriver.java:22)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:221)
at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:213)
at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:190)
at com.kms.katalon.selenium.driver.CInternetExplorerDriver.(CInternetExplorerDriver.java:15)
at com.kms.katalon.core.webui.driver.DriverFactory.createNewIEDriver(DriverFactory.java:449)
at com.kms.katalon.core.webui.driver.DriverFactory.startNewBrowser(DriverFactory.java:240)
at com.kms.katalon.core.webui.driver.DriverFactory.openWebDriver(DriverFactory.java:191)
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.doCall(OpenBrowserKeyword.groovy:74)
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.call(OpenBrowserKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 17 more

@ravneet.boparai I am not sure if that is an Admin issue but the overall approach in dev / QA teams is that they should have full admin rights on the machines. This would speed up many things.

I also saw a post which says you need admin rights to run test on IE

Thank You @manpreet.mukkar ,can you suggest anything for running the script on firefox as it is not working on firefox.

@ravneet.boparai Did you changed the default location of firefox when you reinstalled it ? That might be automatically changed as you don’t have admin rights.

Give this post a read and let us know if it works ?

Location of my FF is “C:\Users\RB\AppData\Local\Mozilla Firefox” and I think that’s the only issue because when i type “firefox” in command line it gives an error as ‘firefox’ is not recognized as an internal or external command,
operable program or batch file.

will try changing it on getting the admin rights.

Thank You @manpreet.mukkar