Brown A
Brown A

Reputation: 979

browser.click not working in safari

I have the following test in nightwatch:

browser.click('test')

The browser.click function works in chrome but not safari. Does anyone know why it doesn't work in safari?

Upvotes: 1

Views: 963

Answers (3)

William
William

Reputation: 600

I have had similar issues, a solution for me was to click using Xpath. You can uses Xpath text():

 browser.useXpath()
        .click('XpathToElement')

also i would inject JS to the browser and try to force a click.

browser.execute(function(){
  document.getElementById("nodeId").click();
},[])

However be aware that this does not always solve the issue.

Upvotes: 0

I was having the same problem and apparently the element that I was trying to click on was not in the viewport yet.

I added browser.maximizeWindow() before triggering the click event.

browser.maximizeWindow();

I also included waitForElementVisible('.test',1000) before calling click().

Upvotes: 0

Andy Pohl
Andy Pohl

Reputation: 253

I have experience this as well, but in your case my best guess is that you're not passing in a correct element, like a class. Example:

browser.click('.test')

What is the 'test' that you're trying to click?

Upvotes: 0

Related Questions