MachinePublishers / jBrowserDriver

A programmable, embeddable web browser driver compatible with the Selenium WebDriver spec -- headless, WebKit-based, pure Java
Other
809 stars 143 forks source link

JBrowser for Whatsapp web #293

Open bromoapp opened 6 years ago

bromoapp commented 6 years ago

My client requires me to monitor incoming whatsapp messages to process Purchase Order that sent by his agents on the field. They used to use Telegram for that matter, but since our government banned Telegram (like a month ago), they look for solution using whatsapp.

Currently I'm still in the state of researching the right solution, so I use JBrowserDriver from here

My code currently is like below snippet:

public static void main(String[] args) { JBrowserDriver driver = new JBrowserDriver(Settings.builder() .headless(false) .userAgent(UserAgent.CHROME) .javascript(true) .ssl("trustanything").build()); driver.get("https://web.whatsapp.com/"); } From the snippet above, I deliberately set headless to false so I can see in popup browser, to check whether whatsapp web is properly opened.

My problem is: whatsapp web seems to understand that the request I made isn't from the real browser (e.g. IE, Firefox, Chrome and etc)... so Instead a page that has QR code for login, I got redirected to a page that recommend me to use REAL browser.

How can we go around this problem?

Thanks

hollingsworthd commented 6 years ago

Also on Settings, try Settings.builder() ... .requestHeaders(RequestHeaders.CHROME) -- maybe that makes a difference.

Otherwise there is always some trickery that can be done to detect whether someone is using a particular browser. Perhaps in this case Chrome Headless or Chrome via Xvfb (on linux) would be more useful--check out the Selenium Chrome driver.

Would still be interested in figuring out what's causing this but don't have time at the moment myself to look into it.

GrzegorzDrozd commented 6 years ago

Hi.

I think you should consider some other form of communication. Look for a communicator/instant messages platform with API for sending and receiving messages.

If you are afraid of third-party listening on your communication you can always use PGP encrypted emails to send orders. They can be easily fetched from email server, decrypted and then you can process them. Easy to send - using any modern email client or even some script with simple form etc.

JBrowser is for automatic testing.

Thank you and have a nice day.

hollingsworthd commented 6 years ago

^^

bromoapp commented 6 years ago

Add RequestHeaders.CHROME isnt help :( Regarding using IM besides Whatsaap is not my decision. It's client's choice.