Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to click on a XCUIElementTypeSwitch element #323

Open
MightyAtomm opened this issue Dec 19, 2024 · 1 comment
Open

Failed to click on a XCUIElementTypeSwitch element #323

MightyAtomm opened this issue Dec 19, 2024 · 1 comment

Comments

@MightyAtomm
Copy link

Hi,
What I want to do is to click on a Switch type element, but failed.
server log indicates that the Switch element is not hitable, does anyboy konws how to perform this action to turn on/off a switch? Thanks.
My code:

def test_home_app_launch(mac_driver):
    mac_driver.find_element(by=AppiumBy.XPATH,
                            value='//XCUIElementTypeMenuButton[@label="Home"]').click()
    time.sleep(1)
    mac_driver.find_element(by=AppiumBy.IOS_PREDICATE,
                            value='elementType == 54 AND title CONTAINS "Home Settings"').click()
    time.sleep(1)
    switch_element = mac_driver.find_element(
        by=AppiumBy.IOS_PREDICATE,
        value='elementType == 40 AND label CONTAINS "Show Suggested Scenes"'
    )
    # location = switch_element.location
    # size = switch_element.size
    #
    # tap_x = location['x'] + size['width'] / 2
    # tap_y = location['y'] + size['height'] / 2

    if switch_element.get_attribute("value") == "1":
        switch_element.click()
        # mac_driver.tap([(tap_x, tap_y)])

    assert switch_element.get_attribute("value") == "0", "Switch should be disabled"

failed log:

[0b2948cf][HTTP] --> POST /session/0b2948cf-3798-43dc-9aa3-5f23ad18a48f/element/EB1A49F0-2829-43B5-8569-8B6F9246B081/click {}
[0b2948cf][Mac2Driver@8a82] Driver proxy active, passing request on via HTTP proxy
[0b2948cf][WD Proxy] Matched '/session/0b2948cf-3798-43dc-9aa3-5f23ad18a48f/element/EB1A49F0-2829-43B5-8569-8B6F9246B081/click' to command name 'click'
[0b2948cf][WD Proxy] Proxying [POST /session/0b2948cf-3798-43dc-9aa3-5f23ad18a48f/element/EB1A49F0-2829-43B5-8569-8B6F9246B081/click] to [POST http://127.0.0.1:10100/session/506073F6-2CA0-48DC-9819-0286496DD4AB/element/EB1A49F0-2829-43B5-8569-8B6F9246B081/click] with body: {}
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.53s Find the "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.61s Click "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.61s     Wait for com.apple.Home to idle
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.62s     Find the "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.70s     Check for interrupting elements affecting "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.72s     Synthesize event
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.77s         Scroll element to visible
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.78s             Scroll Table (Identity Binding) by dx: -210.21, dy: -21.17
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.78s                 Wait for com.apple.Home to idle
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.78s                 Find the Table (Identity Binding)
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.86s                 Check for interrupting elements affecting Table
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     6.87s                 Synthesize event
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     7.06s                 Wait for com.apple.Home to idle
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     7.07s         Find the "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     7.23s         Failed: Not hittable: Switch, {{668.1, 746.2}, {39.3, 23.9}}, label: 'Show Suggested Scenes'
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.24s     Retrying `Click "Show Suggested Scenes" Switch` (attempt #2)
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.24s         Wait for com.apple.Home to idle
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.24s         Find the "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.37s         Check for interrupting elements affecting "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.39s         Synthesize event
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.44s             Scroll element to visible
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.44s                 Scroll Table (Identity Binding) by dx: -210.21, dy: 0.00
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.44s                     Wait for com.apple.Home to idle
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.45s                     Find the Table (Identity Binding)
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.63s                     Check for interrupting elements affecting Table
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     8.65s                     Synthesize event
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     9.06s                     Wait for com.apple.Home to idle
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     9.07s             Find the "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =     9.25s             Failed: Not hittable: Switch, {{668.1, 746.2}, {39.3, 23.9}}, label: 'Show Suggested Scenes'
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.25s     Retrying `Click "Show Suggested Scenes" Switch` (attempt #3)
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.26s         Wait for com.apple.Home to idle
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.26s         Find the "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.39s         Check for interrupting elements affecting "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.41s         Synthesize event
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.46s             Scroll element to visible
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.47s                 Scroll Table (Identity Binding) by dx: -210.21, dy: 0.00
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.47s                     Wait for com.apple.Home to idle
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.47s                     Find the Table (Identity Binding)
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.55s                     Check for interrupting elements affecting Table
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.56s                     Synthesize event
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.83s                     Wait for com.apple.Home to idle
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    10.84s             Find the "Show Suggested Scenes" Switch
[0b2948cf][WebDriverAgentMac] [xcodebuild] t =    11.01s             Failed: Not hittable: Switch, {{668.1, 746.2}, {39.3, 23.9}}, label: 'Show Suggested Scenes'
[0b2948cf][WebDriverAgentMac] [xcodebuild] XCTExpectFailure: matcher accepted Assertion Failure: Not hittable: Switch, {{668.1, 746.2}, {39.3, 23.9}}, label: 'Show Suggested Scenes'
[0b2948cf][WebDriverAgentMac] [xcodebuild] 2024-12-19 22:21:32.721799+0800 WebDriverAgentRunner-Runner[54465:18034409] Issue type: 0
2024-12-19 22:21:32.721870+0800 WebDriverAgentRunner-Runner[54465:18034409] Enqueue Failure: Not hittable: Switch, {{668.1, 746.2}, {39.3, 23.9}}, label: 'Show Suggested Scenes' ((null)) (null) 0 0
[0b2948cf][WD Proxy] Got response with status 200: {"value":null,"sessionId":"506073F6-2CA0-48DC-9819-0286496DD4AB"}
@mykola-mokhnach
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants