base.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from seleniumbase import BaseCase
  2. class Tweet(object):
  3. def __init__(self, tweet=''):
  4. namerow = tweet + 'div.media-heading '
  5. self.fullname = namerow + '.fullname'
  6. self.username = namerow + '.username'
  7. self.date = tweet + 'div.media-heading .heading-right'
  8. self.text = tweet + '.status-content-wrapper .status-content.media-body'
  9. self.retweet = tweet = '.retweet'
  10. class Profile(object):
  11. fullname = '.profile-card-fullname'
  12. username = '.profile-card-username'
  13. protected = '.protected-icon'
  14. verified = '.verified-icon'
  15. banner = '.profile-banner'
  16. bio = '.profile-bio'
  17. class Timeline(object):
  18. newest = 'div[class="show-more status-el"]'
  19. older = 'div[class="show-more"]'
  20. end = '.timeline-end'
  21. none = '.timeline-none'
  22. protected = '.timeline-protected'
  23. class Conversation(object):
  24. main = '.main-tweet'
  25. before = '.before-tweet'
  26. after = '.after-tweet'
  27. replies = '.replies'
  28. thread = '.reply'
  29. tweet = '.status-el'
  30. tweet_text = '.status-content'
  31. class Poll(object):
  32. votes = '.poll-info'
  33. choice = '.poll-meter'
  34. value = 'poll-choice-value'
  35. option = 'poll-choice-option'
  36. leader = 'leader'
  37. class Media(object):
  38. container = '.attachments'
  39. row = '.gallery-row'
  40. image = '.still-image'
  41. video = '.gallery-video'
  42. gif = '.gallery-gif'
  43. class BaseTestCase(BaseCase):
  44. def setUp(self):
  45. super(BaseTestCase, self).setUp()
  46. def tearDown(self):
  47. super(BaseTestCase, self).tearDown()
  48. def open_nitter(self, page=''):
  49. self.open(f'http://localhost:5000/{page}')
  50. def search_username(self, username):
  51. self.open_nitter()
  52. self.update_text('input', username)
  53. self.submit('form')
  54. def get_timeline_tweet(num=1):
  55. return Tweet(f'#tweets > div:nth-child({num}) ')