base.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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-circled'
  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. class Conversation(object):
  47. main = '.main-tweet'
  48. before = '.before-tweet'
  49. after = '.after-tweet'
  50. replies = '.replies'
  51. thread = '.reply'
  52. tweet = '.timeline-item'
  53. tweet_text = '.tweet-content'
  54. class Poll(object):
  55. votes = '.poll-info'
  56. choice = '.poll-meter'
  57. value = 'poll-choice-value'
  58. option = 'poll-choice-option'
  59. leader = 'leader'
  60. class Media(object):
  61. container = '.attachments'
  62. row = '.gallery-row'
  63. image = '.still-image'
  64. video = '.gallery-video'
  65. gif = '.gallery-gif'
  66. class BaseTestCase(BaseCase):
  67. def setUp(self):
  68. super(BaseTestCase, self).setUp()
  69. def tearDown(self):
  70. super(BaseTestCase, self).tearDown()
  71. def open_nitter(self, page=''):
  72. self.open(f'http://localhost:8080/{page}')
  73. def search_username(self, username):
  74. self.open_nitter()
  75. self.update_text('.search-bar input[type=text]', username)
  76. self.submit('.search-bar form')
  77. def get_timeline_tweet(num=1):
  78. return Tweet(f'.timeline > div:nth-child({num}) ')