Submit form using tampermonkey by clicking a submit type button - tampermonkey

Im trying to create a script that clicks a button.
the button I need to click on:
<input type="submit" name="press" value="submit" />
I can't find a way to press that type of button.

Firstly, you should include these two lines, so that you can use jQuery:
// #require http://code.jquery.com/jquery-2.1.0.min.js
// #run-at document-end
And then all of this will work:
$( "input[tpye='submit']" ).click();
$( "input[name='press']" ).click();
$( "input[value='submit']" ).click();
or alternatively:
$('#form_id').submit();

Related

angular ui tooltip triggers ng-disabled of other buttons when hover on button

I using ui bootstrap tooltip plugin with something like this:
<button type="button" uib-tooltip="new item">
new item
</button>
<button ng-disabled="vm.testDisabled()">
search
</button>
angular.module('rgh').controller('CourseController', CourseController);
function CourseController () {
function testDisabled() {
console.log('testDisabled called')
return false;
}
}
but the problem is that when i hover on new item button, i see the testDisabled called logs in chrome console, i think its inappropriate behavior from uib-tooltip.
how can i resolve this problem?
It's not inappropriate, it's how angular works! when you pass over your button and the tooltip shows the digest loop runs, because you've provided your ngDisabled with a function, that function will run on each digest cycle (even when it is not needed) because it's returned result will be used to tell angular if it should disable the input or not!!
To avoid this, pass ngDisabled with a variable that will be changed in your controller on certain conditions
<button ng-disabled="vm.isTestDisabled">
search
</button>

Make submit from angular controller

I have
var x = angular.element(document.getElementById('campito'[0]
.attributes[2].submit; that show ng-submit="submit(campito)"
How can I trigger the submit from the controller
I have a form:
<form name="campito" id="campito" ng-submit="submit(campito)">
</form>
and a button outside de form:
<button type="submit" class="btn btn-primary sh-depth-1" form="campito" ng-disabled="!esAdmin || isLoad">
<strong>Guardar</strong>
</button>
Is angular 1.4.4, in chrome the button works fine, but in IE9 donĀ“t work, I tried to change the type attribute to ng-attr-type in the button, because it is a bug, but it does not work either. Therefore what I can think of is to create a function and trigger it from the same button and within this function trigger the submit, I already get inside the function to obtain the object of the form, but I can not trigger it.
With:
var x = angular.element(document.getElementById('campito'))[0];
obtain the complete form
With:
var x = angular.element(document.getElementById('campito'))[0].attributes[2];
The ng-submit attribute.
After that I could not.

Angular input type submit don't prevent form submit on ng-click

All I want to accomplish is to show a "loading ..." when the submit button is clicked using AngularJS.
I figured that should be quite easy using
<form ng-if="!export.buttonClicked">
... various input values without ng-model
<input type="submit" value="Start export" class="btn btn-default" ng-click="export.buttonClicked=true;">
</form>
<div ng-if="export.buttonClicked">
loading...
</div>
How could I be so wrong. Seems like Angular prevents the default form submission like this. Showing the loading div works quite fine, but I need the form to be submitted (The server has to calculate a lot so it responds slowly and I would like to show loading... instead of the Button once it has been clicked)
I can't use ng-submit because I have to combine AngularJS with Razor and I don't want no ng-form or ng-model...
Any ideas?
If you have an angular controller tied to the page or div, just use a function in your ng-click like this:
<div ng-controller="sampleController" style="text-align:center">
<button ng-click="buttonClickedFunction()">Submit</button>
<p>{{message}}</p>
</div>
Then in your controller:
yourAppName.controller('sampleController', function($scope) {
$scope.buttonClickedFunction = function() {
$scope.message = "Loading...";
// Whatever else you wish to do with your button/function.
};
});
This puts loading on the screen once button is clicked, if this is what you were shooting to do?

Unable to click on the Submit button using selenium webdriver

I have a submit button on my UI page but I am not able to click on that button even if I take the XPath of that. Below is the UI code for button
<input type="submit" class="btn btn-primary btn-lg col-sm-2" value="Submit">
but the XPath i am getting is
//*[#id="form"]/div[5]/input
So please provide me some inputs to select the button. I also need to scroll down the page a bit as the button is also not visible on the page.
u may try by using cssSelector like below:
driver.findElement(By.cssSelector(".btn.btn-primary.btn-lg.col-sm-2"));
for this, class "btn.btn-primary.btn-lg.col-sm-2" must be unique.
if the element is not visible in the screen, than use like below:
JavascriptExecutor js = (JavascriptExecutor)driver;
WebElement elem = driver.findElement(By.cssSelector(".btn.btn-primary.btn-lg.col-sm-2"));
//this line will scroll down to make element visible
js.executeScript("window.scrollTo(" + elem.getLocation().x + "," +(elem.getLocation().y- 100) + ");");
than click on that element:
elem.click();
Hi please use this xpath it will work
//*[#id='form']/div[5]/input // if nodes are correct then
if yor page has got only on tag with attribute value value="Submit" then
//*[#value='Submit']
You can try following xpath
//input[#class='btn btn-primary btn-lg col-sm-2']
this should work

ng-click doesn't work inside script

I am using the angular-bootstrap in AngularJS, because I want to use dialogs. In my HTML I have the following code:
<script type="text/ng-template" id="create.html">
<div class="modal-header">
<h3 class="modal-title">Welcome!</h3>
</div>
<div class="modal-body">
<p>Hi</p>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
</div>
The modal dialog shows up, but nothing happen when I click on the "OK" button.
There is also no error in the console. When I create a button and place it outside the script, then it works. But I need to use the button in the modal dialog.
I have created a factory for the modal dialog, because I want to use it in my controller. Here the function what works fine:
$scope.createGame = function(data){
// Open the modal dialog
ModalFactory.open();
}
Now the modal dialog shows up and the button "OK" appears. When I click on "OK" nothing happen. This is the function I have created for the "OK" button.
$scope.ok = function(data){
// Close the modal dialog
alert("Test");
}
But the triggering of ng-click in that script what you see above doesn't work...
Your function requires a parameter "data" but you are not passing it.
<button class="btn btn-primary" ng-click="ok()">OK</button>
Either Change your function signature like this,
$scope.ok = function(){
// Close the modal dialog
alert("Test");
}
Or Pass the data.
It's always use a different function name rather than just "ok"

Resources