How to set useragent for phantomjs in serenity-bdd? - serenity-bdd

how do we set a user-agent for phantomjs in serenity-bdd ?
for ex: I want to write automated tests for mobile-site. In this case, how do i provide phantomjs a mobile user-agent ?
Or is there another way to test mobile site thru serenity-bdd ? Not on real devices though. I specifically want mobile-site tested

How would you do this in native WebDriver?

Related

Phantomjs jquery dialog popup

I can handle it with FF web driver (selenium python) but when I change phantomjs the driver .it didnt handle it. is it possible to handle it?
the program must work on server so what must I do?
In short, no, this is not currently possible. The PhantomJS ghostdriver does not implement the primitives for handling alerts/prompts. See https://github.com/detro/ghostdriver/issues/20
This is also unlikely to change since development of PhantomJS has been discontinued.
the program must work on server so what must I do?
Your best option is to use the headless versions of Chrome or Firefox, which can run in a headless environment like PhantomJS just fine. Both Chrome (chromedriver) and Firefox (geckodriver) implement the necessary primitives for handling alerts/prompts.
Another option is that you can use a virtual screen program (e.g. xvfb) to enable you to use a headed browser in a headless environment.

Record browser sessions via selenium-webdriver

Is there a way to record / generate a video file of the browser session for selenium webdriver with the following setup?
Environment / Test Setup:
e2e web tests (written in any language)
selenium standalone server with chrome
Since, there is no direct support from selenium, you may use third party tool like Monte Media Library. See the link:
How to perform screen recording with the help of selenium?
Hope, this will help you.

Can we use Sikuli with PhantomJS?

I want to use Sikuli with PhantomJS.Because web application which we are testing have so many http authenticate pop Ups. We are automating those pop ups by using Sikuli when we were using Selenium. But now we want to use PhantomJS because user is not able to do any other work while selenium web driver is performing testing on web application. Basically we don't want to block User for doing any other activity. So we are trying to use PhantomJS.
But as we know that PhantomJS is headless browser and Sikuli is image based testing tool . So can we use Sikuli With PhantomJS? If yes, then how can We use it? I know how to use Sikuli with PhantomJS Webdriver?
Thanks In Advance
No, you can't. As you stated PhantomJS is headless browser and Sikuli is image based testing tool, so there's no GUI to interact with.
Get some Virtual Machines and run tests on them, so no user is blocked.

Working with multiple APIs for Multi-platform apps

I currently have a Chrome extension that uses Chrome's APIs and plan on making a Microsoft Edge version once it opens up as well. My question is how do you work with the multiple API's?
For example, I use the following to check if the extension has just been installed or not:
chrome.runtime.onInstalled
I'm assuming for Edge it would be something like:
edge.runtime.onInstalled
What's the best way to work with both of these? Do I just duplicate the code within the file where there is a copy of the code for one and the other and presumably the browser will ignore the other browser's code? (doesn't sound like the good option)
Or is there some cross-browser framework that I should use instead?
Or is there some other solution?
And please forgive me, this is my first entry into building extensions/apps, I'm generally just a Web Designer.
Thank you!
All browsers support or
chrome.runtime.onInstalled
or
browser.runtime.onInstalled
So, the right way is to start scripts in your extension with this code:
var browser = browser || chrome
And then use browser, for example:
browser.runtime.onInstalled
(I'm sorry about my english)
Edit:
Chrome and Opera support chrome and not browser.
Firefox support chrome and browser.
Edge support browser and I don't know if it support chrome.
Anyway, my solution work in all browsers.
Update (5.8.16):
Edge support browser and not chrome.

Restricting Selenium/Webdriver/HtmlUnit to a certain domain

While using selenium/webdriver for web scraping, I realized the target site has google analytics script running. Is there a way to restrict selenium/webdriver/htmlunit to avoid certain urls/domains ?
Thanks,
I think it is impossible becouse Selenium is actually adapter for several implementation. So he can't deny to load some scripts to firefox or chrome. Perhaps you can check driver api(firefox profile, htmlunit configuration file) to accomplish this.