def check_type(self, how, what):
if how == 'index':
if not isinstance(what, int):
raise TypeError('expected {}, got {!r}:{}'.format(int, what, what.__class__))
elif how == 'visible':
if not isinstance(what, bool):
raise TypeError('expected {}, got {!r}:{}'.format(bool, what, what.__class__))
elif how == 'visible_text':
if type(what) not in [six.text_type, six.binary_type, re._pattern_type]:
raise TypeError('expected str or regexp, got {}')
else:
if isinstance(what, list) and how != 'class_name':
raise TypeError("only 'class_name' locator can have a value of a list")
if type(what) not in self.VALID_WHATS:
raise TypeError(
'expected one of {}, got {!r}:{}'.format(self.VALID_WHATS, what, what.__class__))
评论列表
文章目录