1
は私がlocators.pyTypeError例外:%のためのサポートされていないオペランドのタイプ(S): 'タプル' と 'str' は
class MainPageLocatars(object):
# Login function locators
TEST = "//*[starts-with(@id,'table_')]/tbody/tr[%s]"
を持って、私は以下のように、このロケータを呼び出しています:
INDEX_MAP = {
'First': '1',
'Last': 'last()'
}
# all locaters for this class are defined here only
class ListView(Page):
def __init__(self, driver, index):
if index not in INDEX_MAP:
raise ValueError("Invalid index %s" % index)
self.driver = driver
self.row = self.driver.find_element_by_xpath(MainPageLocatars.FRAMEONE % (INDEX_MAP[index])
このそれを行う正しい方法ですか?
これは私が取得していますエラーです:
self.row = self.driver.find_element_by_xpath(MainPageLocatars.FRAMEONE % (INDEX_MAP[index]))
self.row = self.driver.find_element_by_xpath(MainPageLocatars.FRAMEONE % (INDEX_MAP[index]))
TypeError: unsupported operand type(s) for %: 'tuple' and 'str'
明らかに、 'MainPageLocatars.FRAMEONE'はタプルです。 '%'はそれに何を期待していましたか? – jonrsharpe
投稿されたコードによると、 'MainPageLocatars'は' FRAMEONE'属性を持っていません... –
'MainPageLocatars.FRAMEONE%(INDEX_MAP [index]、))の最後に"カンマ " '。 –