base.py 2.0 KB

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