Upgrade to 1.9 from 1.8.1 Issue


#1

Hi. I upgraded from appium 1.8.1 to 1.9. I am receiving the below message
this code works with 1.8.1 but 1.9
e = @selenium.find_element :class_name, ‘XCUIElementTypeNavigationBar’
puts e.name
return e

appium -v
1.9.0

npm list wd
/Users/raytrejo
└── [email protected]

gem list
selenium-webdriver (3.14.0)

Locator Strategy ‘css selector’ is not supported for this session (Selenium::WebDriver::Error::InvalidSelectorError)
InvalidSelectorError: Locator Strategy ‘css selector’ is not supported for this session
at XCUITestDriver.validateLocatorStrategy (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:349:13)
at XCUITestDriver.validateLocatorStrategy (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:111:21)
at XCUITestDriver.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:26:8)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at new Promise ()
at new F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.callee$0$0 [as findElOrElsWithProcessing] (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/build/lib/basedriver/commands/find.js:47:30)
at XCUITestDriver.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:46:21)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at new Promise ()
at new F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.callee$0$0 [as findElement] (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/build/lib/basedriver/commands/find.js:88:30)
at /usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:296:26
at tryCatcher (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromiseAtPostResolution (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:248:10)
at Async._drainQueue (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:128:12)
at Async._drainQueues (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:693:18)
at tryOnImmediate (timers.js:664:5)
at processImmediate (timers.js:646:5)
./iOS/features/lib/views/siteList_screen.rb:17:in `/^I should see the “(.*?)” test site button on Site List screen$/’


#2

npm uninstall -g appium (That’s will remove all appium from your pc)

After it’s done:
npm install -g [email protected]


#3

i performed your recommended steps
Same issue persists. Any other suggestions.
Thank you ,
Ray


#4

I am trying to find an element by its class_name.

The error “Locator Strategy ‘css selector’ is not supported for this session” suggests its trying to use css?


#5

After running npm uninstall -g appium, check if all the relevant folders are deleted and then do npm install -g appium

you can skip providing version number while running installation command, npm will pick the latest from source.


#7

Hi guys,
I tried all of this, but transition from 1.8 to 1.9.0 appium still makes me issues (not working).

I define elements like this:
def sign_in_button(self):
return WebDriverWait(self.driver, Constants.wait_time).until(
EC.presence_of_element_located((By.ID, “btnBottom”)))

LOG:

debug] [W3C] Calling AppiumDriver.findElement() with args: [“css selector”,"[id=“btnBottom”]",“ae0ee547-d111-4c31-9fdd-303ea23eef0b”]
[debug] [XCUITest] Executing command ‘findElement’
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[W3C] Encountered internal error running command: InvalidSelectorError: Locator Strategy ‘css selector’ is not supported for this session
[W3C] at XCUITestDriver.validateLocatorStrategy (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:349:13)
[W3C] at XCUITestDriver.validateLocatorStrategy (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:111:21)
[W3C] at XCUITestDriver.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:26:8)
[W3C] at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[W3C] at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[W3C] at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
[W3C] at new Promise ()
[W3C] at new F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
[W3C] at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
[W3C] at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[W3C] at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
[W3C] at XCUITestDriver.callee$0$0 [as findElOrElsWithProcessing] (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/build/lib/basedriver/commands/find.js:47:30)
[W3C] at XCUITestDriver.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:46:21)
[W3C] at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[W3C] at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[W3C] at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
[W3C] at new Promise ()
[W3C] at new F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
[W3C] at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
[W3C] at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[W3C] at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
[W3C] at XCUITestDriver.callee$0$0 [as findElement] (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/build/lib/basedriver/commands/find.js:88:30)
[W3C] at /usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:296:26
[W3C] at tryCatcher (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/util.js:26:23)
[W3C] at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:510:31)
[W3C] at Promise._settlePromiseAt (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:584:18)
[W3C] at Promise._settlePromiseAtPostResolution (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:248:10)
[W3C] at Async._drainQueue (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:128:12)
[W3C] at Async._drainQueues (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:133:10)
[W3C] at Immediate.Async.drainQueues (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:15:14)
[W3C] at runCallback (timers.js:696:18)
[W3C] at tryOnImmediate (timers.js:667:5)
[W3C] at processImmediate (timers.js:649:5)
[HTTP] <-- POST /wd/hub/session/ae0ee547-d111-4c31-9fdd-303ea23eef0b/element 400 6 ms - 4797


#8

This is the problem with your client library. Make sure it is up to date


#9

I did these commands
npm uninstall -g appium (That’s will remove all appium from your pc)
npm install -g [email protected]
but… my issues remained.

After more debugging and trial an error.
I ended up doing the below from the gitbub install instructions. I still have issues post upgrade
to 1.9.0 but I made some progress after I performed these steps.
gem update --system
gem update bundler
gem uninstall -aIx appium_lib
gem install --no-rdoc --no-ri appium_lib


#10

It worked with update, although my command had to be:

sudo gem install -n /usr/local/bin --no-rdoc --no-ri appium_lib due to permissions issues.

Regular command can give error:
gem install --no-rdoc --no-ri appium_lib
Fetching: nokogiri-1.8.4.gem (100%)
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory.


#11

I have the same problems.

Using Appium 1.7.0/Server v1.9.0 with Robotframework test for Android apps.

I’m using ID locators, ex:
Wait Until Element Is Visible id=${appPackagename}:id/welcome_section_top_empty

When running the test, I get error:
InvalidSelectorException: Message: Locator Strategy 'css selector' is not supported for this session

I tried going back to Appium 1.6.3/Server v1.8.1, but then I have another problem running test for iOS apps. As soon as I start the tests, I get:
WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Xcode version '0.0'. Support for Xcode 0.0 is not supported. Please upgrade to version 7.3 or higher

The same iOS test will run fine with Appium 1.7.0/Server v1.9.0


#12

In case someone faced the same problem when upgrading to 1.9.1, here’s my workround.

Solved InvalidSelectorError: Locator Strategy ‘css selector’ is not supported by following steps:

  1. Go to /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py

  2. Comment out the section where Selenium rewrites selectors to CSS, do the same for find_elements.

    def find_element(self, by=By.ID, value=None):
    “”"
    Find an element given a By strategy and locator. Prefer the find_element_by_* methods when
    possible.

     :Usage:
         element = driver.find_element(By.ID, 'foo')
    
     :rtype: WebElement
     """
     # if self.w3c:
     #     if by == By.ID:
     #         by = By.CSS_SELECTOR
     #         value = '[id="%s"]' % value
     #     elif by == By.TAG_NAME:
     #         by = By.CSS_SELECTOR
     #     elif by == By.CLASS_NAME:
     #         by = By.CSS_SELECTOR
     #         value = ".%s" % value
     #     elif by == By.NAME:
     #         by = By.CSS_SELECTOR
     #         value = '[name="%s"]' % value
    
     return self.execute(Command.FIND_ELEMENT, {
         'using': by,
         'value': value})['value']