Not able to click on the Add button - reactjs

<div class="MuiGrid-root jss48321 MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-3 MuiGrid-grid-md-3 MuiGrid-grid-lg-3 MuiGrid-grid-xl-3">
<h4 class="MuiTypography-root jss48324 MuiTypography-h4">Decks</h4>
<button class="MuiButtonBase-root MuiFab-root jss48323 MuiFab-sizeSmall MuiFab-primary" tabindex="0" type="button" aria-label="add" title="Add">
<span class="MuiFab-label">
<svg class="MuiSvgIcon-root" focusable="false" viewBox="0 0 24 24" aria-hidden="true">
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path>
</svg>
</span>
<span class="MuiTouchRipple-root"></span>
</button></div>
Since it is react js application, I added
browser.waitForAngularEnabled(false);
Here I wanted to click on the add icon (+)
My test script:
describe('IEC', function () {
it('Login', function () {
browser.waitForAngularEnabled(false);
browser.get('cannot provide the url since it requires VPN');
element(by.css('input[type="text"]')).sendKeys('12345');
element(by.css('input[type="password"]')).sendKeys('Pwd');
element(by.buttonText('Login')).click();
element(by.css('button[title="Add"]')).click();
});
});
Output:
Failed: No element found using locator: By(css selector, button[title="Add"])
How can I resolve this issue?#

Protractor has built in waiting specific to Angular pages. Your page is react, and by running browser.waitForAngularEnabled(false); you disable that waiting
Now your code just does what you instruct it to: set username and password and click submit. Probably 5 milliseconds later you attempt to click add button? but it's not present. I'm pretty sure it's will take at least 10 seconds to load the application after logging in. So you need to add that step. Either browser.sleep(15000) which is VERY bad practice, of add explicit wait for a condition using browser.wait
Also, each line of your code returns Promise, but you don't handle it. The side effect is the order of your commands is not guaranteed. I already told you this in previous posts you need to use async/await. Unless you do so, you'll be having thousands of problems, I guarantee

Related

Cypress clicking on a button with href"..." does not return information that it should

I am working with react app and have a href button that supposed to take me the new url but also load some information for a dropdown on the next page. below is the button code
<a class="MuiButtonBase-root MuiButton-root MuiButton-text jss1069 depth-2 jss1073" tabindex="0" role="button" aria-disabled="false" href="...." aria-current="page">
<span class="MuiButton-label">Programs</span>
<span class="MuiTouchRipple-root">
<span class="MuiTouchRipple-ripple MuiTouchRipple-rippleVisible" style="width: 276.159px; height: 276.159px; top: -126.08px; left: -69.0797px;"></span></span></a>
My cypress code i tried to click on it.
cy.get('button[style="padding-left: 40px;"]',{timeout: 10000})
.should('be.visible')
.click()
cy.get('a[href="......"]')
.should('be.visible')
.click()
i tried getting it with href ,with contains, timing out visible and etc. it does click on it but then API call behind it does not load info i need and show errors on Cypress runner even tho it returned 200.
This is runner screen in yellow shows that weird error and consol says "you need a javascript to run this app". I have js enabled aswell on browser.
Runner screen
I added exception handling and it worked few runs and then started doing the same thing
cy.get('a[href="/setup/academics/programs"]')
.should('be.visible')
.click()
Cypress.on('uncaught:exception', (err, runnable) => {
return false
})
Any input is highly appreciated
I could see that your application is generating exceptions. To handle exceptions you can add this after the click.
Cypress.on('uncaught:exception', (err, runnable) => {
return false
})

Using Recurly payment form with React results in large blank iFrames. Styling removes fields

Recurly instructions on how to build a form
Github repository that demonstrates the problem.
My form:
<form id="recurly_form">
<div data-recurly="number"></div>
<div data-recurly="month"></div>
<div data-recurly="year"></div>
<div data-recurly="cvv"></div>
<button onClick={this.handleFormSubmit} >
Place order
</button>
</form>
I make every attempt to make sure the configure call is made after everything is mounted and ready:
componentDidMount() {
$(() => {
window.recurly.configure({
publicKey: "ewr1-xxxxxxxxxxxxxxxxx"
});
});
}
The end result is a tall blank screen with a button:
Markup looks like this:
Note that the month field is set to visibility:hidden. Also note that the <div data-recurly="number"></div> is empty. That is the result of me trying to style it with the styles offered in the instructions.
Please advise on what's missing.

How to handle dynamic web-element for icon references in selenium webdriver. Can anyone help me out?

In my application, dynamic elements are used which are basically icon/CSS selector references; for ex - save, delete, cancel buttons. These elements doesn't works with xpath's as i have tried with most of the ways. My reading is that the CSS selector will work for these elements. but i'm unable to find it out. Below is the HTML for the same.
Parent class is <div class="rTableCell ActionCell">
under this class <a> tag is used given like below
<a class="SaveRow" onclick="UpdateInlineData(event,'49b3f007-fbc5-492c-b609-8b24a3044ee1','GridDesignation','../MasterData/ManageDesignation')" data-toggle="tooltip" data-original-title="Save" >
under this class <i> tag is used like given below
<i class="fa fa-floppy-o themeSaveIcon"></i>
<div class="rTableCell ActionCell" style="height: 88px;"><a class="SaveRow" onclick="UpdateInlineData(event,'49b3f007-fbc5-492c-b609-8b24a3044ee1','GridDesignation','../MasterData/ManageDesignation')" data-toggle="tooltip" data-original-title="Save"><i class="fa fa-floppy-o themeSaveIcon"></i></a><a class="CancelRow" onclick="ResetInlineData(event,'49b3f007-fbc5-492c-b609-8b24a3044ee1','GridDesignation','../MasterData/ResetDesignation')" data-toggle="tooltip" data-original-title="Cancel"><i aria-hidden="true" class="fa fa-times themeCancelIcon"></i></a></div>
try action chains on selenium API
if you user python you can see this document
for example you have
xpath_element = "a xpath address"
from selenium.webdriver.common.action_chains import ActionChains
hover = ActionChains(self.driver).move_to_element(xpath_element)
hover.click().perform()
you can perform more actions on hover depending on your purpose

Angular - diff in IE and Chrome

I have two button that are overlapping, and use ng-hide for the m with the same flag.
On Chrome it work perfectlly, but when I use IE 11, the icons are overlapping on page load.
I have two icons on in my search box:
And On IE11, when the page is loading:
The code is:
<button type="submit" class="btnSubmit" ng-show="vm.isSearchIconVisible" >
<i class="iconMglass"></i>
</button>
<button type="reset" ng-show="!vm.isSearchIconVisible" class="clearTextButton" ng-click="vm.clearSearchText()">
<span class="clearIcon">X</span>
</button>
How can I fix it ?
Try using ng-ifinstead of ng-show.
The ng-if directive removes the content from the page and ng-show/ng-hide uses the CSS display property to hide content.
Not using CSS by changing to ng-if prevents these CSS problems. Although the ng-ifcreates a new scope but that impact is nothing.
<button type="submit" class="btnSubmit" ng-if="vm.isSearchIconVisible" >
<i class="iconMglass"></i>
</button>
<button type="reset" ng-if="!vm.isSearchIconVisible" class="clearTextButton" ng-click="vm.clearSearchText()">
<span class="clearIcon">X</span>
</button>
If you don't want to change to ng-if, then please share a working Plunkr/... so help you find your problem. Since it will be a cssissue most likely.
The Problem was that IE11 save cash with old code, CTR+R dident solve this problem.
In the IE11 option I revoce the option to save cash and it solve the problem, the new code appear.

protractor expect not working for non-angular accordion widget

After clicking on the accordion element, the accordion panel opens, but the expect() in the following code passes even though the desired panel has been expanded (aria-expanded="true"). I am trying to verify the correct panel has been opened. I am new to protractor - any help will be appreciated.
var el = element(by.css('#brainstormingLink'));
el.click().then(function(){
browser.sleep(1000).then(function(){
expect(element(by.css('#BrainstormingAccordion[aria-expanded="false"])).isPresent());
});
});
The HTML is as follows:
<h3 id="brainstormingLink" class="menuSectionLink ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-corner-top" sectionnum="1" role="tab" aria-controls="BrainstormingAccordion" aria-selected="true" tabindex="0">Brainstorm</h3>
<div id="BrainstormingAccordion" class="accordion-inner scrollable ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" aria-labelledby="brainstormingLink" role="tabpanel" aria-expanded="true" aria-hidden="false" style="display: block; height: 282px; overflow: auto;">
Follow these steps to brainstorm ideas:<br><br>
<ol>
<li>Use the add idea button <div class="toolbarButtonIcon inlineIcon"><div id="icon-plus"> </div></div> to enter one idea, fact, or opinion about your topic that you think might be useful.</li>
<li>Continue using the add idea button <div class="toolbarButtonIcon inlineIcon"><div id="icon-plus"> </div></div> to add as many ideas as you can.<br><br>
<div class="buttoncenter"><button class="btn btn-custom" type="button" name="brainstorming" title="brainstorming"> about brainstorming</button></div>
</li>
</ol>
</div>
Your test always passes because you didn't complete the assertion in the expect statement. .isPresent() returns a boolean so you need to finish it with whatever you are expecting the result to be i.e .toBe(false) or .toBeTruthy() etc.
Just note that isPresent is really asking if that element is present in the page, if you want to know if it's currently visible to a user then use .isDisplayed(). Also, since that element has an ID, I think you're better off locating it that way like you did with the first element, the HTML attribute isn't necessary unless you had trouble locating it. I always use ID when it's available because they're unique.
List of available assertions here: http://jasmine.github.io/2.0/introduction.html

Resources