How to check if a webelement has attribute in Python? or What's the best way to verify a webelement h

16 Replies, 743 Views

If you’re into one-liners, you could do:

```python
has_class = 'class' in element.get_attribute('outerHTML')
```

But... it’s hacky and might break if the HTML formatting changes.

For webelement has attribute python, I’d still recommend `get_attribute() + None` check. Boring but reliable.

Messages In This Thread



Users browsing this thread: 1 Guest(s)