Protractor adding request headers - angularjs

I'm using protractor to test app that requires custom headers.
I am using for this 'modify headers' extension in chrome. How can I set them in protractor?

Actually is not possibly to add custom headers because of a limitation of Webdriver. There is an issue raised Protractor and Selenium, please refer to this thread: https://github.com/angular/protractor/issues/740:
Protractor (and webdriver, which it is built on top of) are intended to test your application like a user interacting with your page, so the meaning of browser.get is something like 'do what would happen if a user opened up a new tab and entered this URL'. So, there's no way to interact with under the hood things like setting headers, except for in the way that it would normally get done for your user.
Hope it helps.

Related

Is there a way to automate voice calls using Selenium Java

Is there a way to automate voice calls using Selenium Java
I have a requirement where , i need to click the call button available in my website and provide the inputs and get the responses based on the input.
Is there any way we can achieve this using selenium
Can you add some additional details to understand the problem.
If you are talking about IVR Testing I don't think you can achieve it using Selenium and Java.
For IVR Testing you can use tools like CYARA or HAMMER, you can find the details in below link.
https://www.softwaretestinghelp.com/ivr-testing-tools/
If the scenario is upon click call button if you get popup or window opens.
Where you need to provide details, It can be done by switching to popup/window using switchTo() and send the input using sendKeys(),
If you want to test the output which is a call/voice it can't be done.

How to use Selenium WebDriver to find Firefox add-ons warning dialog

I am testing downloading and installing an add-on that our company makes. I can add the domain to the Firefox profile whitelist to eliminate the first dialog, but then FF displays a second one that says "Install add-ons only from authors whom you trust". I can't find a way for Selenium to find it. It's the one that looks like this:
I have tried driver.switchTo().alert().accept() - this is not an alert.
I have tried driver.switchTo().findElement(linkText("Install") - nothing found.
I have tried using SikuliWebDriver to find an element by location (picking some random ints to work off of) and then just send keys like Keys.TAB and Keys.ENTER, but as I step through in debug mode, driver.findELementByLocation(20,40) never returns.
I have tried driver.getKeyboard().sendKeys(Keys.TAB) (sending two tabs and an enter). Also never returns.
I think this dialog is generated by Javascript but I am unable to find out what JS generates it. Ideally I could find a name or an id for the button in the dialog and then use JavascriptExecutor to run the command. But without any kind of handle I'm stuck.
Any ideas?
Selenium can only see the DOM (document object model). It can't test desktop applications. The dialog shown is part of the Firefox application and not part of the DOM, so Selenium can't see or access or interact with it. Sad but true. Try Ranorex?

How do I make selenium see the network requests made by a web browser?

I have a dotnet Selenium web driver app.
When I'm testing the page one of the things I need to confirm is that a flash object on the page has pulled correct content from a content store on my site. (i.e. the flash object should be loading content from /stuff/info.txt and including that content within the animation.)
As a human looking at this I can use the chrome network tab and see that /stuff/info.txt has been accessed.
How can I make Selenium execute a similar watch and see the network requests made by a web browser?
I did not wrote this, neither tested it however someone did it here: http://www.softwareishard.com/blog/firebug/automate-page-load-performance-testing-with-firebug-and-selenium/
Basically all the requests are exported via netexport and firebug plugins inside a HAR (Http ARchive file)
Please give us your feedback if you give it a try!
Cheers !
I assume you want to automate the process which the developer tools of browsers does. Something like firebug but for verification using Code.
I don't believe Selenium has such features. For now, you will not be able to achieve this.

Browser Automation with Selenium: Fingerprints, recognizability and traceability?

I want to use selenium/webdriver to simulate a browser and scrape some website-content with it. Even if its not the fastest method, for me it has many advantages such as executing scripts etc.
For many websites it is forbidden to access them via an automated method, for example search engines like google or bing.
For one tool i need to scrape the estimated resultstat from google for several keywords. This will look like the following: simulate the browser that visits google.com and types in a keyword and scrapes the results, then after a little pause type in the next keyword, scrape the results and so on...
My question is: Is it possible for a website to recognize that I'm using selenium to simulate the browser instead of using the browser by hand? Especially the google case gives me some doubts. I know selenium is partly developed by google or at least by some guys working for google. So does leave selenium some fingerprints or isn't it possible to decide if I'm using the browser by myself or simulated by selenium, even for google?
No, nobody can actually see that you're using Selenium and not hand-operating the browser yourself with WebDriver. I'm not sure about the old Selenium RC, but it should be the same way. Here's how it works:
Selenium opens up a browser with a clean profile (or with a profile you selected)
Selenium is hooked up to the browser so it can steer it, control it. But the browser still does most of the work. Basically, Selenium replaces the user inputs to the browser, but not more.
You can easily verify this by reading the contents of the HTTP headers sent by your browser.
If you ever actually needed Selenium to be recognized by your server, you can use Browsermob-proxy and add a custom header to your requests.
All that said, there is one thing you must be aware of. While there's no way to detect Selenium directly, there can be some indirect clues picked up by the website you're visiting. Those usually include scanning for too many requests made in virtually no time - this might be an issue for you. Make sure your Selenium is behaving like a user.
EDIT 2016/04:
Apparanetly it is possible as https://stackoverflow.com/a/33403473/2930045 states that a company can do it. My guess - and it is nothing but a guess - is that they can run some JS that Selenium installs into the browser to operate.
Signs point to yes, sites are able to regonize that you are using Selenium.
Counter Example: www.stubhub.com detects and blocks my browser instance launched using Selenium while "normal" browsing done manually (not using the browser launched by the Selenium web driver) work with out issue.
See this stackoverflow question for additional details
Can a website detect when you are using selenium with chromedriver?

how to verify the tooltip in extjs application with selenium ide

I learning automation of application with selenium ide.The application which I am currently testing is a extjs application.In this application all the required validations are shown in the tooltip.For ex: I have password form in which new password and confirm password are the two fields and there is a submit button.If the password entered in the new and confirm password field do not match then "Password do not match" message is shown in the tooltip and the submit button is disabled.In this case how to verify the tooltip and its contents in the selenium.
Plz can anyone suggest some solution to the above problem?All validation in my application are shown in the tooltip.
thanks,
sushi
First, make sure that you explicitly assign ids to your fields. Otherwise, it will be very hard to get a hold of the components with the automatically generated ids (like "ext-comp-004").
The strategy is to use the verifyEval Selenium command and use the Ext JS API to do certain things.
For checking the active error message of a field with id "password_confirm", you can use:
Ext.getCmp("password_confirm").getActiveError();
First, try this in the Firebug console manually to make sure it works for you. Then you can do the same in your Selenium script as:
Command: verifyEval
Script: Ext.getCmp("password_confirm").getActiveError()
Expected: Passwords do not match
If you want to test this out with Selenium IDE in Firefox first, you should take into account that the window object will be wrapped in a XPCNativeWrapper. You can access the actual window object and the Ext JS namespace in it through wrappedJSObject:
Command: verifyEval
Script: window.wrappedJSObject.Ext.getCmp("password_confirm").getActiveError()
Expected: Passwords do not match
For some general tips on testing Ext JS applications with Selenium, see this answer. Some parts of it may be outdated, but can still give you an idea about the general strategies involved.

Resources