Protractor Testing not working - protractor

The question is related to protractor testing. I am testing an application using Protractor. I want to inspect one element but unable to get the solution. The HTML code for the element to be inspected is :
<span class="ng-binding"> Admitted(7)</span>
As in selenium we do
element(by.class....) is not possible here in protractor. So Can any one help me in this.

You can also inspect in protractor as
element(by.css('span ng-binding'))
or
element(by.css('ng-binding'));
If there are more than one element with class name "ng-binding",
then use
element.all(by.css('ng-binding'))
to inspect element.

Related

Sweetalert: e2e testing using 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.

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);

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.

iPhone webdriver not locating element using CSS selector

iPhone webdriver is not able to locate DOM elements using CSS selectors. I'm running the test on iPad simulator. In news.yahoo.com, trying to select an element using findElement(By.cssSelector()).
None of the below works. I can locate the element by id and xpath but css selector doesn't work. Getting no such element exception. Is this is a known issue? Any pointer would be helpful. Thanks!
findElementByCssSelector("mediamostpopular")
or
findElement(By.cssSelector("mediamostpopular"))
or
executeScript("document.querySelector('#mediamostpopular');"));
With the Given Information I am able to see the ID #mediamostpopular.
In Selenium We can find the element given below as follows.
driver.findElement(By.id("mediamostpopular")).

Selenium beginner question

I am just trying to understand and learn selenium. I used IDE to record my actions and tried to playback but I am kind of stuck on the first step.
What I am trying is basically login to our internal site and then click on menu bar to navigate to an internal page. Selenium logs in but fails at the click event with error message -
[error] Element css=#ui-active-menuitem > span.wijmo-wijmenu-text > span.wijmo-wijmenu-text not found
This site is generated using primeface and when I see the source code, the line that generate error is something like-
<div align="left" class="container"><div id="menu"><ul id="menu_menu"><li><a href="javascript:void(0)">
<span class="wijmo-wijmenu-text">Home</span></a><ul><li>home</li></ul>
</li><li><span class="wijmo-wijmenu-text">Tills</span><ul>
<li>Manage........
I must tell here that as long as I am not clicking on above menu item, I am able to run all tests through Selenium ID but clicking on above menu after login is essential to get to inner pages.
You help/guidance is much appreciated.
Thanks
I'm begining too and having same problem. This commands work for me:
clik
link=menuName
clickAndWait
link=subMenuName
Hope it helps.
Maybe element not found just because it not loaded yet.After log in you can try to use command
waitForElementPresent and then click on element.
It seems you refer to an element by css, you can try id or name
I think before appearing the menu Selenium trying to click.
Just use
Thread.sleep(5000); // for five second waiting or more you can use
Another way use -
WebDriverWait wait = new WebDriverWait (driver, 30); // maximum wait 30 seconds
wait.until(ExpectedConitions.PresenceofElement(By.id("Menu_id"))).click();
Add wait and never try learning selenium through IDE .
disadvantages of using IDE is you cannot add conditions ,loops and wait in your code and cannot maintain the framework.