Forum Discussion

mortenb123's avatar
mortenb123
Contributor
6 years ago

python exception on ClickItem() not caught

I have some usb smartcards that switches adressing based on windows discovery, so they can show up ending with either 0 or 1, but I'm unable to catch when the clickitem() does not exists, it always f...
  • mortenb123's avatar
    6 years ago

    Just to follow up. I rewrote the test to use dropdown and choose that is fetched:

     

     

      #Selects the 'Gemalto USB Smart Card Reader 1' item of the 'ComboboxOperatorCardReader' combo box.
      reader = "Gemalto USB Smart Card Reader"
      app.MainWindow.TabControl2.TabControlConfig.ItemsControl.ComboboxOperatorCardReader.Click()
      ComboBox = app.MainWindow.TabControl2.TabControlConfig.ItemsControl.ComboboxOperatorCardReader
      for i in range(ComboBox.wItemCount):
        Item = aqString.GetListItem(ComboBox.wItemList, i)
        if reader in Item:
          Log.Message(f"found {Item}")
          app.MainWindow.TabControl2.TabControlConfig.ItemsControl.ComboboxOperatorCardReader.ClickItem(Item)
          break
    
      reader = "Gemalto IDBridge CT7xx"
      ComboBox = app.MainWindow.TabControl2.TabControlConfig.ItemsControl.ComboboxOperatorCardReader
      # focus object missing name, Accessibility Insight gives error
      ComboBox.Click(335, 13)
      Sys.Keys("[Tab]")
      for i in range(ComboBox.wItemCount):
        Item = aqString.GetListItem(ComboBox.wItemList, i)
        if reader in Item:
          Log.Message(f"found {Item}")
          app.MainWindow.TabControl2.TabControlConfig.ItemsControl.ComboboxOperatorCardReader.ClickItem(Item)
          break 
    

     

    But in selenium try/except catches everything, must easier with exception handling.