using Cucumber with Netzke to call an action in Grid Panel - cucumber

I'm working on Rails(3.1.3) with Netzke(0.7.3).
I very new for Cucumber.
add_account_for_user.feature
Feature: Add Account For User Feature
In order to add login account
As an Administrator
I want to add login account for other role
Scenario: Adding Login Account
When I login as an Administrator
Then I should be on admin page
When I click on 'Administration' button at right upper of page
Then I should see 'Administrator Management'
And I should see 'Add' button in Administrator Management toolbar
When I click on 'Add' button
Then I wait 10 seconds # for check what happen
The problem is at When I click on 'Add' button step.
It pass but not working correctly. (It should fire event onAddInForm)
It's hanging in loading and do not show new windows panel.
my_steps.rb
Then /^(?:|I )click on '(\w*)'(?:|.*)$/ do |label|
click_link_or_button(label)
step "wait for the response from sever"
end
When /^(?:|I )wait for (?:.*)$/ do
page.driver.browser.execute_script(<<-JS)
JS
end

Found the solution!!
The solution is try to collect Component that you use. and then call that action directly.
When /I press 'Add' button in the '(\w*)' grid$/ do |grid_name|
page.driver.browser.execute_script <<-JS
var containerComp = Ext.getCmp("main_container");
var grid = containerComp.down("#"+"#{grid_name.underscore}_grid");
grid.onAddInForm();
JS
end
But I still don't understand why it not call onAddInForm after click.

Related

Goggle - Cannot create credentials

Cannot create credentials, when I click the "Create credentials" button in the credentials page in console.cloud.google.com, the page will show a list, "API Key", "OUauth client ID", etc as you can see in my screenshot. I want to create an API Key, but the option cannot be clicked, when i set my cursor to the option, "Navigation menu" tooltip appears, and when clicked, it will show the page menu. How do I fix this? Anyone have similar issue? I'm using chrome, trying in firefox but to no avail.

Toggle login logout not working in react js, when we refresh page then it is not working (means Navbar Components not changing)

If we press login, and do log in process successful then login button remove from Navbar and Log out button displayed but problem is that when we press log out then log out working successfully but after pressing logout still logout is there in Navbar instead of showing Login (If we refresh then working properly)
not sure what code have you written just follow below approach:
First create a state(default value false) as shown below:
let [authenticated, setauthenticated]= React.useState(false);
when your user successfully logged in then just update that state to true as shown below:
setauthenticated(true)
In JSX just check if the user is authenticated the show them Logout component otherwise signup/login according to your requirement
{authenticated ? <Logout/> : <Signup/> }

wait for page load for non-angular Application using protractor

i am new to protractor and testing Non-Angular login Page and on clicking login button on login page a new page appears and i need to click on a planning link.But on clicking Login button application takes around 50 seconds.I want the protractor to wait untill the planning link appears.I used browser.wait(),browser.driver.implicitltyWait() but no success. I am able to click on planning link using browser.sleep() only.
Please help me to resolve the issue.
You need to wait for any WebElement in the page that is loaded after you perform login operation.
var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(element(by.id("someId"))),60000)
it will wait for the element and throw exception after waiting for 1 minute
So what I understood from your question is that you have a non angular login page and click on login button takes you to another page(Is this angular or non angular?) which takes around 50 sec to load and contains a link(planning). Right?? And clicking on that link will take you to your angular home page.
And the issue which you are facing now is that the protractor is not waiting 50sec for the page containing the planning link to load.
Please try this and let me know the result..
this.clickLoginBtn = function () {
browser.driver.findElement(loginBtn).click();
return browser.wait(function () {
return browser.driver.isElementPresent(planningLink);
}, 50000);
};
I used browser.driver.findElement since we are on the non angular page.
I wrote a blog post about this, and have working examples on github, specifically when testing non-Angular apps. It makes use of Expected Conditions, and Page Objects.
If you're not using Page Objects yet, you'd do something like:
var EC = protractor.ExpectedConditions;
// Waits for the element with id 'loginBtn' to be clickable.
browser.wait(EC.elementToBeClickable($('#loginBtn')), 50000);

How to fix Google Calendar API error

I following https://developers.google.com/google-apps/calendar/quickstart/nodejs#step_3_set_up_the_sample
But it not worked and output below this:
var clientSecret = credentials.installed.client_secret;
^
TypeError: Cannot read property 'client_secret' of undefined
at authorize (/Users/prangyy/myApp/quickstart.js:32:43)
at processClientSecrets (/Users/prangyy/myApp/quickstart.js:21:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:404:3)
Change lines 34-36 in quickstart.js to:
var clientSecret = credentials.web.client_secret;
var clientId = credentials.web.client_id;
var redirectUrl = credentials.web.redirect_uris[0];
(There's an error where they've used credentials.installed instead of credentials.web, which is what shows up in the client_secrets.json file.)
Try checking your client_secret.json in the Node.js Quickstart.
It should contain clientID, auth_url, token_uri, auth_provider_x509_cert_url, client_secret, redirect_uris, javascript_origins.
{"web":{"client_id":"YOUR_CLIENT_ID","project_id":"google.com:my-project-1231","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"YOUR_CLIENT_SECRET","redirect_uris":["YOUR_REDIRECT"],"javascript_origins":["YOUR_JAVA_ORIGIN"]}}
if not yet, follow this to get your client_secret.json file
Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click the Save button.
Select the Credentials tab, click the Create credentials button and select OAuth client ID.
Select the application type Other, enter the name "Google Calendar API Quickstart", and click the Create button.
Click OK to dismiss the resulting dialog.
Click the file_download (Download JSON) button to the right of the client ID.
Move this file to your working directory and rename it client_secret.json.
I hope this helps. Goodluck :)
No need to modify the original code if you check 'Other' (as said in the tutorial) when you choose your Application type in the client ID creation page (step 4 of your pasted text)

I want to know that when download of a file is completed at client side when he/she try to download a file from my application

In my application , I have to provide a download button, so that when user clicks on it he/she can download file.
Right now in my application i have a feature that when user clicks on download button , I disable my download button until download pop-up is opened.
Now, I want that when download completes on client side , then download button should be enable to the client.
I want to know that is it possible ? If yes , then please tell me how can i achieve that.
From the [link][1] i Pasted , you can do this using jQuery :
Suppose you have an
<input id="FileDownload" type="button" name="FileDownload">Download</input>
You can define a jQuery event on the Click of this button
$("#FileDownlaod").click(function(){
this.disabled=true; //Disables the input button
/Call the plugin as described in the link
//On Success this.disabled=false
});

Resources