0

I'm trying to parse the last received message from Pushbullet. I'm currently doing it using Clicks, which means that I do every single clicks, sendkeys and all the rest needed actions automatically. In other words it is just a simulation of the user. One of the biggest con of the method is that whenever xpath or a class or id of the element changes which I'm aiming with Selenium, whole cycle fails and the test case can not proceed operating.

I want to change the way I'm doing. Particularly, I want to send a json request to Pushbullet API and then get the response in return.

I just couldn't decide from where and how to start doing.

Could you guys please tell me the way from where should I start and what are the steps that needs to be covered in order to finally reach the finish line?

Thank you in advance.

CEH
  • 5,701
  • 2
  • 16
  • 40
Shako
  • 31
  • 9

1 Answers1

0

I noticed that this question is tagged under Selenium, but in your question, you express interest in switching to an API approach. I will try to provide some advice to you on this.

Selenium Approach

  • You mention that you tests are brittle, and if anything changes then they fail. This is usually the case with UI tests. If you would like to stick with the Selenium approach, I can try to help you write more robust locators for your WebElements that will not break constantly.

API Approach

You will need to start with the Pushbullet API documentation -- https://docs.pushbullet.com/

To get messages, it looks like you will want to use the chat endpoint -- a sample request looks like this: https://api.pushbullet.com/v2/chats, plus authentication.

Once you fetch the chat objects, you will need to write your own logic to parse each chat object and fetch the most recent message from there.

Depending on what language you are using, you will need to install a REST client package onto your project. I use C#, so RestSharp is the client I like to use.

I recommend installing a REST client interface, such as Postman, to start practicing your API calls. Once you get your API calls working in Postman, you can start writing code to make these API calls.

What other questions do you have about this?

CEH
  • 5,701
  • 2
  • 16
  • 40
  • To be honest, I currently have a ready code and it works with MYSMS.COM, but I don't like some specific things in MYSMS. I tried to rebuild the current code and adapt it with PUSHBULLET but I could do it. I will show you the code if it says more: – Shako Sep 26 '19 at 15:12
  • mysms and Pushbullet have different API documentation and specifications, so none of the syntax or request body will be the same -- that's probably why it doesn't work. I'll try to update your codeshare with a starting point for you. – CEH Sep 26 '19 at 15:42
  • @Shako I've updated your codeshare with a few details from Pushbullet API. I'm not sure if you need to use the `list-pushes` or `list-chats` method from Pushbullet though, you can update your endpoint accordingly. – CEH Sep 26 '19 at 15:49
  • I think I'm on the right way now. Another problem occurs here. I have attached few devices on one account and I want to parse the last received message (which is one time code). Example: One of the devices is Galaxy S9, I want to choose the device (S9), go to conversations and parse the last received message from the conversation with the name "John". I have read all the documents given on api.pushbullet.com, but could not reach my goal. Could you please help me to follow the right path? Thank you in advance – Shako Sep 27 '19 at 10:37
  • JObject res returns the following response: {{"accounts": [],"blocks": [],"channels": [], "chats": [],"clients": [],"contacts": [],"devices": [],"grants": [],"pushes": [],"profiles": [], "subscriptions": [],"texts": []} @Christine – Shako Sep 27 '19 at 12:29
  • I'm not very familiar with Pushbullet or how their API works with your setup. If you've checked their documentation and couldn't find anything, it's possible that their API doesn't support the behavior you are trying to implement. If that is the case, Selenium may be a better approach. – CEH Sep 27 '19 at 15:12