base.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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-container'
  19. self.unavailable = quote + '.quote.unavailable'
  20. class Tweet(object):
  21. def __init__(self, tweet=''):
  22. namerow = tweet + '.tweet-header '
  23. self.fullname = namerow + '.fullname'
  24. self.username = namerow + '.username'
  25. self.date = namerow + '.tweet-date'
  26. self.text = tweet + '.tweet-content.media-body'
  27. self.retweet = tweet + '.retweet-header'
  28. self.reply = tweet + '.replying-to'
  29. class Profile(object):
  30. fullname = '.profile-card-fullname'
  31. username = '.profile-card-username'
  32. protected = '.icon-lock'
  33. verified = '.verified-icon'
  34. banner = '.profile-banner'
  35. bio = '.profile-bio'
  36. location = '.profile-location'
  37. website = '.profile-website'
  38. joinDate = '.profile-joindate'
  39. mediaCount = '.photo-rail-header'
  40. class Timeline(object):
  41. newest = 'div[class="timeline-item show-more"]'
  42. older = 'div[class="show-more"]'
  43. end = '.timeline-end'
  44. none = '.timeline-none'
  45. protected = '.timeline-protected'
  46. photo_rail = '.photo-rail-grid'
  47. class Conversation(object):
  48. main = '.main-tweet'
  49. before = '.before-tweet'
  50. after = '.after-tweet'
  51. replies = '.replies'
  52. thread = '.reply'
  53. tweet = '.timeline-item'
  54. tweet_text = '.tweet-content'
  55. class Poll(object):
  56. votes = '.poll-info'
  57. choice = '.poll-meter'
  58. value = 'poll-choice-value'
  59. option = 'poll-choice-option'
  60. leader = 'leader'
  61. class Media(object):
  62. container = '.attachments'
  63. row = '.gallery-row'
  64. image = '.still-image'
  65. video = '.gallery-video'
  66. gif = '.gallery-gif'
  67. class BaseTestCase(BaseCase):
  68. def setUp(self):
  69. super(BaseTestCase, self).setUp()
  70. def tearDown(self):
  71. super(BaseTestCase, self).tearDown()
  72. def open_nitter(self, page=''):
  73. self.open(f'http://localhost:8080/{page}')
  74. def search_username(self, username):
  75. self.open_nitter()
  76. self.update_text('.search-bar input[type=text]', username)
  77. self.submit('.search-bar form')
  78. def get_timeline_tweet(num=1):
  79. return Tweet(f'.timeline > div:nth-child({num}) ')