appium-safari-driver icon indicating copy to clipboard operation
appium-safari-driver copied to clipboard

Clicks are not working on pages

Open MB1lal opened this issue 3 years ago • 3 comments

I have setup Appium project in java which uses appium-safari-driver to automate web page. I have noticed that it's not able to click on elements. For example: If I am trying to login a user it enters username and pass correctly but fails to click.

Although there is no failure that is shown in logs or something but the click never happens. I have only tested this on iOS simulator as of now.

These are the capabilities I am using:

SafariOptions capabilities = new SafariOptions()
                 .setPlatformVersion("15.5")
                 .setAutomationName("Safari")
                 .setSafariDeviceName("iPhone 13 mini")
                 .setSafariUseSimulator(true)
                 .setPlatformName("iOS");

and using page factory to click an element

 @FindBy(css = "button.radius")
    private WebElement loginButton;

 @Step
    public void clickLogin() {
        loginButton.click();
    }

Below are the Appium logs for click function:

[HTTP] --> GET /session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/context
[HTTP] {}
[SafariDriver@df56 (f7a22faf)] Driver proxy active, passing request on via HTTP proxy
[debug] [SafariDriver@df56 (f7a22faf)] Matched '/session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/context' to command name 'getCurrentContext'
[debug] [SafariDriver@df56 (f7a22faf)] Proxying [GET /session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/context] to [GET http://127.0.0.1:5100/session/6434438A-00A7-4EA5-AFB0-07C1A1E3CD3E/context] with no body
[SafariDriver@df56 (f7a22faf)] Got response with status 404: {"value":{"error":"unknown command","message":"The command 'GET /session/6434438A-00A7-4EA5-AFB0-07C1A1E3CD3E/context' was not found.","stacktrace":""}}
[debug] [W3C] Matched W3C error code 'unknown command' to UnknownCommandError
[HTTP] <-- GET /session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/context 404 6 ms - 757
[HTTP] 
[HTTP] --> POST /session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/element
[HTTP] {"using":"css selector","value":"button.radius"}
[debug] [SafariDriver@df56 (f7a22faf)] Calling AppiumDriver.findElement() with args: ["css selector","button.radius","f7a22faf-ff5e-4136-bbdf-a693fa3370c7"]
[debug] [SafariDriver@df56 (f7a22faf)] Valid locator strategies for this request: xpath, tag name, link text, partial link text, css selector, id, name
[debug] [SafariDriver@df56 (f7a22faf)] Matched '/element' to command name 'findElement'
[debug] [SafariDriver@df56 (f7a22faf)] Proxying [POST /element] to [POST http://127.0.0.1:5100/session/6434438A-00A7-4EA5-AFB0-07C1A1E3CD3E/element] with body: {"using":"css selector","value":"button.radius"}
[debug] [SafariDriver@df56 (f7a22faf)] Got response with status 200: {"value":{"element-6066-11e4-a52e-4f735466cecf":"node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8"}}
[debug] [SafariDriver@df56 (f7a22faf)] Responding to client with driver.findElement() result: {"ELEMENT":"node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8","element-6066-11e4-a52e-4f735466cecf":"node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8"}
[HTTP] <-- POST /session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/element 200 15 ms - 147
[HTTP] 
[HTTP] --> POST /session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/element/node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8/click
[HTTP] {"id":"node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8"}
[SafariDriver@df56 (f7a22faf)] Driver proxy active, passing request on via HTTP proxy
[debug] [SafariDriver@df56 (f7a22faf)] Matched '/session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/element/node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8/click' to command name 'click'
[debug] [SafariDriver@df56 (f7a22faf)] Proxying [POST /session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/element/node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8/click] to [POST http://127.0.0.1:5100/session/6434438A-00A7-4EA5-AFB0-07C1A1E3CD3E/element/node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8/click] with body: {"id":"node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8"}
[debug] [SafariDriver@df56 (f7a22faf)] Got response with status 200: {"value":null}
[HTTP] <-- POST /session/f7a22faf-ff5e-4136-bbdf-a693fa3370c7/element/node-7EF03BAC-80A0-4C47-BAA5-9781C4B597C8/click 200 34 ms - 14
[HTTP] 

MB1lal avatar Jul 21 '22 16:07 MB1lal

The log looks completely fine from Appium perspective. Consider reporting the issue to Apple

mykola-mokhnach avatar Jul 21 '22 16:07 mykola-mokhnach

I've posted my page utilities, there are some alternatives you can try to direct clicks. Safari is always tricky.

Try this one --> click_element_coordinates() https://gist.github.com/DanEdens/ed5cb453bd97f6ee3eeb5b180a997502

MadTinker avatar Feb 24 '23 01:02 MadTinker

In my case it's doing a long-press if I add timeout before the finish. I'm guessing that it's pressing down and never releasing up or something like that...

Maxim-Mazurok avatar Dec 27 '24 13:12 Maxim-Mazurok