base.py 2.8 KB

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