How can I handle Geo Location popup in browser using karate? [duplicate] - karate

This question already has answers here:
Handling Basic Authentication in Karate UI scenario
(2 answers)
Closed 1 year ago.
I need to allow the geo location during my karate web automation test.
I was going through this documentation https://github.com/intuit/karate/tree/master/karate-core
It has information on handling dialog boxes and popup but they don't seem to be working for the geo location pop up

Thanks to the comment above, looks like for Chrome you can use the addOptions to pass disable-geolocation:
* configure driver = { type: 'chrome', addOptions: [`disable-geolocation`] }
I guess it would be similar for other browsers. If needed please consider submitting a PR to the project.
Also note that we are working on Karate Robot that may be able to solve this in the future.

Related

Input text into multiple alert text fields before action [duplicate]

This question already has answers here:
Selenium - Basic Authentication via url
(6 answers)
Unable to handle Microsoft login authentication popup in headless chrome[Selenium using java]
(1 answer)
How to manage Basic Authentication login with selenium c#?
(2 answers)
Python Windows Authentication username and password is not working
(2 answers)
Closed 1 year ago.
I need to input text into the two fields in an alert window like this one as an example:
I've looked at the doc for keyword Input Text Into Alert, but it doesn't seem to consider multiple text fields and actually I can't even get it to accept one text (alert detection goes timeout).
How is this achievable through RF/SeleniumLibrary?
I found this similar question:
Robot framework handle an authentication popup
I don't know if anything has changed since then, but the accepted answer solves the problem manipulating the URL, even if without using RF+SeleniumLibrary (which I would have preferred).

How to enable Downloading PDF files through Karate ChromeDriver? [duplicate]

This question already has answers here:
API Automation Testing : Is there any way to automate download scenario with content validation?
(2 answers)
Closed 1 year ago.
When PDF hyperlinks selected using karate chromedriver, the files are opening in new tab rather than downloaded to the local system. I tried with below ChromeOptions while configuring the driver, but none of them looks worked for me.
karate.configure('driver;, {type:'chromedriver', executable: path, webDriverSession:{desiredCapabilities:{browserName:'chrome', "goog:chromeOptions":{"prefs": {"pdfjs.disabled": true}}}}});
Below preferences also did not work.
"prefs": {"plugins.always_open_pdf_externally": true,"plugins.plugins_disabled", "Chrome PDF Viewer"}
I went through karate docs but couldn't find a similar topic. I really appreciate if anyone can help me with this issue or guide me to the documentation.
Downloading files via WebDriver happens to be listed among their worst practices. The recommendation is to just get the URI from the DOM and use whatever http client you have available.
Thanks Peter & Matthias for the idea. I am able to download the file after updating the element DOM structure using JavaScript.
var lnkName = element.attribute['href'];
script("document.getElelmentById('pageLinks').setAttribute('download','"+lnkName+"');");
element.click();
I strongly suggest that in this case you just get the hyperlink of the PDF and use the Karate API testing functionality to download the file anywhere you want. You can find tips here: How to get the downloaded xlsx file from the api endpoint in karate? - and also look at the "upload.feature" example in the Karate demos.
If you need to execute some JS to get the final URL of the file, that is quite possible: https://stackoverflow.com/a/60800181/143475
Otherwise you need to continue doing some research, I don't know the answer and hopefully you can contribute your findings back.

Passing data between scenarioes in karate [duplicate]

This question already has an answer here:
Karate API Testing - Reusing variables in different scenarios in the same feature file
(1 answer)
Closed 1 year ago.
I have a requirement to pass the response of first web services to next service. We maintain one scenario for each web services. Some of the tags in first services needs to be passed to next web services within the feature file itself. Please help.
Thanks,
Thiyagu
I think you have fundamentally misunderstood the way a Scenario works. Each Scenario is supposed to be independent. You can't have one Scenario update a variable and then expect that other ones can see the updated value. Please combine your 'flows' into one Scenario. Or if some 'setup' steps are common, use a Background section.
Keep in mind that you should be able to comment-out a Scenario or skip some via tags without impacting any others.

How can I get page status code using behat + mink with selenium driver?

Selenium does not support this code
$statusCode = $this->getSession()->getStatusCode();
It is possible to check status any other way?
This is not what Selenium was designed for. One of their project member in reply to request to implement this in Selenium said:
We will not be adding this feature to the WebDriver API as it falls outside of our current scope (emulating user actions).
The solution is to either use another driver that supports status codes, or try to implement one of available hacks (given in other stack overflow questions asking the very same thing).
You can use Restler, a micro framework which supports behavior Driven API testing using Behat and Guzzle.
For example (see: status_codes.feature):
#restler
Feature: HTTP Status Codes
Scenario: I should be able to suppress status code 404
When I request "/examples/_001_helloworld?suppress_response_codes=true"
Then the response status code should be 200

how can i test whether my server supports range requests? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I find out whether a server supports the Range header?
I want to make a jPlayer media player but it says that the server must enable Range requests.
It says that this is easy to check for by seeing if your server's resonse includes the Accept-Ranges in its header - but I don't know how to do this 'easy' thing.
I think it is the same question as How can I find out whether a server supports the Range header? but I need a step by step idiot guide to how to carry out the test. I couldn't work it out from that answer. Can anyone help? I guess I need to upload a php page to my server with some code on it?
Thank you.
OK well apparently this is how you can do it (thanks to Mark Panaghiston at JPlayer for this)..
Navigate to the url address of a video (mp4 in my case) on the server in question in Chrome/Firefox.
Open up the developer tools (in Chrome, shortcut CTRL-SHIFT-i or F12)
Switch to the network tab of the developer tools
Select the video/file in question
Then click for the Headers tab for information
Look to see if you have a Header Response for Accept Ranges: Bytes
If this Accept Ranges has a value like bytes, then it means range requests are accepted.