RobotFramework+Appium 升级Appium v1.10.0后,执行click element时报错:InvalidSelectorException: Message: Locator Strategy 'css selector' is not supported for this session,解决办法
报错信息如下:
debug] [35m[XCUITest][39m Connection to WDA timed out
[debug] [35m[XCUITest][39m Connection to WDA timed out[info] [35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session/0fa5e52b-19f3-4c08-87c7-053b1e9ed018/elements[39m
[info] [35m[HTTP][39m [90m{"using":"css selector","value":"[id=\"SVW_LoginChoiceView.swift130001\"]"}[39m
[debug] [35m[W3C (0fa5e52b)][39m Calling AppiumDriver.findElements() with args: ["css selector","[id=\"SVW_LoginChoiceView.swift130001\"]","0fa5e52b-19f3-4c08-87c7-053b1e9ed018"]
[debug] [35m[XCUITest][39m Executing command 'findElements'
[debug] [35m[BaseDriver][39m Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [35m[W3C (0fa5e52b)][39m Encountered internal error running command: InvalidSelectorError: Locator Strategy 'css selector' is not supported for this session
[debug] [35m[W3C (0fa5e52b)][39m at XCUITestDriver.validateLocatorStrategy (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/lib/basedriver/driver.js:344:13)
[debug] [35m[W3C (0fa5e52b)][39m at XCUITestDriver.validateLocatorStrategy (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/lib/driver.js:918:11)
[debug] [35m[W3C (0fa5e52b)][39m at XCUITestDriver.helpers.findElOrElsWithProcessing (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/lib/basedriver/commands/find.js:28:8)
[debug] [35m[W3C (0fa5e52b)][39m at XCUITestDriver.commands.findElements (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/lib/basedriver/commands/find.js:60:21)
[debug] [35m[W3C (0fa5e52b)][39m at curCommandCancellable._bluebird.default.resolve.then (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/lib/basedriver/driver.js:291:18)
[debug] [35m[W3C (0fa5e52b)][39m at tryCatcher (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/node_modules/bluebird/js/main/util.js:26:23)
[debug] [35m[W3C (0fa5e52b)][39m at Promise._settlePromiseFromHandler (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:510:31)
[debug] [35m[W3C (0fa5e52b)][39m at Promise._settlePromiseAt (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:584:18)
[debug] [35m[W3C (0fa5e52b)][39m at Promise._settlePromiseAtPostResolution (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:248:10)
[debug] [35m[W3C (0fa5e52b)][39m at Async._drainQueue (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:128:12)
[debug] [35m[W3C (0fa5e52b)][39m at Async._drainQueues (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:133:10)
[debug] [35m[W3C (0fa5e52b)][39m at Immediate.Async.drainQueues (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:15:14)
[debug] [35m[W3C (0fa5e52b)][39m at runCallback (timers.js:696:18)
[debug] [35m[W3C (0fa5e52b)][39m at tryOnImmediate (timers.js:667:5)
[debug] [35m[W3C (0fa5e52b)][39m at processImmediate (timers.js:649:5)
[info]
解决办法:
在python文件夹下找到site-pankages/selenium/webdriver/remote/webdriver.py中找到def find_element和def find_elements,注释掉if self.w3c;
保存后,再次运行,成功解决。