Sweetalert: e2e testing using Protractor - protractor

I am trying to test my web application which uses SweetAlert. I am using Protractor for e2e testing.
When I tried selecting an element using
var textElement = element(by.id("newWbName"));
protractor goes into an infinite loop, saying
W/element - more than one element found for locator By(css selector, *[id="newWbName"]) - the first result will be used
as seen here, even though there is only one id with newWbName.
I am wondering if there is anything in how sweet alert renders the alert that is causing this issue? The selectors work fine when I use them on the rest of the page. Any help is really appreciated.

Related

Can't get the DOM in a react app using testcafe

I'm new into testcafe. I have a react app which was made by create-react-app, and I'm trying to do very simple function:
await t.expect(ReactSelector('ReactHighcharts').exists.ok()
I figured out that no matter what component I put inside the selector I get flase.
When I explored more, I saw that react-scripts probably minifies/uglifies by his webpack, my code, and that's
why I can't get the DOM.
Am I right? if yes - how can I disable it? if not, I'd like to understand why the DOM is unreachable.
You can explicitly set the displayName property for a component or consider testing the dev build.
https://reactjs.org/docs/react-component.html#displayname

protractor : Best way to use in protractor ? driver.get("URL") or browser.get("URL")

Which is best way to use in protractor ?
var driver = browser.driver;
driver.get("URL")
or
browser.get("URL")
browser.manage().timeouts().implicitlyWait(browser.params.implicitWaitTime);
Currently I have used second approach to open URL and perform any browser action. Should I change everything like first approach or my approach is nice to go ahead ?
My two cents
If its a non angular application - go For browser.driver.get()
If not go for browser.get('')
browser.get understands the angular cycle and waits for the angular activity to finish
from documentation - API Documentation
Navigate to the given destination and loads mock modules before
Angular. Assumes that the page being loaded uses Angular. If you need
to access a page which does not have Angular on load, use the wrapped
webdriver directly.
If you are using browser.get() then you dont need a implicit wait and ideally you should avoid using it

how to check whether a specific checkbox is checked using protractor

I want to do e2e testing using protractor. My AngularJS application consists of large number of data with checkboxes out of which some will be checked. I want to test whether my required test data are checked.
I tried using below code:
expect(element(by.model("accordoptionGroup[optgroup.id][objopt.id].value")).get(index).isSelected()).toBe(true);
But error saying element(..).get is not a function
Please Help.
.get() method is available on an ElementArrayFinder. You meant to have:
expect(element.all(by.model("accordoptionGroup[optgroup.id][objopt.id].value")).get(index).isSelected()).toBe(true);

Automated Testing (Watir): Retrieving data and implementing into your test?

I am just getting started with automated testing on RubyMine using Watir webdriver. So far I am having a blast and I find it works really well, even for a newb like me! :)
I want to create a test which retrieves an order code that is generated during the test and then later use the same code to run an 'include?' verification query on a different page.
I know I can use an HTML selector to show Watir where the code is, I want to know how to copy it and use it later. Can anyone point me in the right direction?

Multiple polymer element tests with karma test runner

I have written a few tests for polymer elements in jasmine based on how Polymer wrote tests with Mocha for their components.I am able to run those tests successfully if I run them individually.
By taking a look at Polymer's core tests ,what I understand is that there is a custom test runner that uses mocha-htmltest.js to launch each of the polymer element tests(each an html in itself) in an iframe and then destroy it for every test.The results to display are passed to the main window for every test.
In this approach,each polymer element test html running within an iframe imports all the libraries needed(jasmine,platform,polymer).
Isn't this a costly approach to re-construct iframes importing all libraries for each element's test?
Is there any alternate ways for running multiple polymer element tests?
I could not find alternative approaches without one test polluting the other.(Faced issues like being able to listen to polymer-ready only for the first element test)
Can anyone share some thoughts on how you managed to run multiple polymer elements' tests with karma as the test runner?
Thanks,
vj.
We chose the iframe approach because we wanted to write tests in plain HTML without resorting to javascript innerHTML tricks, and we use karma to test in all of our supported browsers. iframes gives us both of our requirements, at the expense of taking a while to run.
I must note that we typically test a number of related things in iframes because the cost is so high. In that sense we use them at somewhere between a "suite" and a "test" in mocha's terminology.
Perhaps at some point in the future, a lighter layer can be made (ES6/7 Realms + ShadowDOM?) that gives us a clean context for our test runs, but the speed hit is not especially heinous to us for now.