base.py 2.5 KB

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