I would like Find_element_by_id on paypal in order to confirm the checkout, but I'm getting an error.
I use a working code with webdriver Chrome and Opera:
confirmButton = browser.wait.until(
EC.presence_of_element_located((By.ID, "confirmButtonTop"))
)
confirmButton.click()
I want to use it with HTMLUnit and PhantomJS, but it doesn't work. I've tried using a different method but nothing:
try:
WebDriverWait(driver, delay).until(EC.presence_of_element_located(
driver.find_element_by_id('confirmButtonTop'))
)
print "Page is driver!"
except TimeoutException:
print "Loading took too much time!"
or:
confirmButton = driver.find_element_by_id("confirmButtonTop")
confirmButton.click()
same error :
Unable to locate element with ID: confirmButtonTop
HTML:
<div id="button" class="buttons reviewButton">
<input track-submit="" type="submit" value="Continuer" id="confirmButtonTop"
class="btn full confirmButton continueButton" validate-submit="onPay()">
</div>
Related
Im new using Selenium Webdriver and i couldn't automate a confirmation javascript onclick button, these button can't inspect to see the xpath;
the html button is:
<input type="button" class="ButtonEnable" name="Reset" id="Reset" value="Borrar todos los contadores " onclick="javascript:CallBack_Reset()">
and i try with the name or id
web_element = driver.find_element(By.NAME, 'Reset').click()
but appear a pop-up window with a confirmation
Update. I resolve it.
I use a selenium condition (alert) to javascript callback push-up windows.
the code to resolve it:
web_element = driver.find_element(By.NAME, 'Reset').click() WebDriverWait(driver, 5).until(EC.alert_is_present(), '¿Desea borrar todos los contadores?') alert = driver.switch_to.alert alert.accept()
Here's my HTML code:
<span>
<button onclick="indexOBJ.clear();return false;" class="resetButton">清空</button>
</span>
Here's my JavaScript code:
var indexOBJ = {
clear: function () {
$('#devSvnURL').val('');
$('#devVersion').val('');
$('#testExampleUrl').val('');
$('#testReportDemoUrl').val('');
$('#resultLocation').val('');
$('#username').val('');
$('#userpwd').val('');
$('#commitTextArea').val('');
$('#note').val('');
}
};
function clearAA() {
alert()
}
It works fine. However when I change my HTML code to:
<span>
<button onclick="clearAA();return false;" class="resetButton">清空</button>
</span>
Then, the function named clearAA() will never be called. I don't know why. Please tell me the reason. Thanks a lot.
Environment: Django 2.0.2 jquery-3.3.1.js
As Daniel said in the question response, this is not a problem from django o jquery. Check in the developer tools if there is some warning or error when you click the button. If not, set a breakpoint in the function you want to call and check if enter in it.
I recommend you to use chrome developer tools.
I have to login a website by providing credentials using Jmeter - WebDriver Sampler in JMeter. And this is my script,
WWDS.browser.get('http://login.salesforce.com')
var pkg = JavaImporter(org.openqa.selenium)
var username = WDS.browser.findElement(pkg.By.id('username'))
username.sendKeys(['prakash93#salesforce.com'])
var password = WDS.browser.findElement(pkg.By.id('password'))
password.sendKeys(['*********'])
var Login = WDS.browser.findElement(pkg.By.cssSelector('button.button-Login'))
button.click()
Every thing is fine except the login button (last 2 lines) . Can anyone help me for login-button's script.
Thanks in advance.
As far as I can see Login button on that page looks like this:
<input class="button r4 wide primary" type="submit" id="Login" name="Login" value="Log In">
I.e.: the element name is input, rather than button, and it doesn't have class named button-Login. So CSS selector button.button-Login is not going to work.
But good news is that button has an id, so you can change it to:
var Login = WDS.browser.findElement(pkg.By.id('Login'))
This is the html code :
...
<div class="span_3_of_4">
<p class="text_popup"> Dont Have an Account? |
<a class="fancybox" href="#load_box">Signup</a>
</p>
</div>
<div class="span_1_of_4" align="center">
<input class="button" type="submit" value="Submit"/>
</div>
</div>
</form>
</div>
<script src="js/jquery.form.js" type="text/javascript"/>
Its a submit button. I am trying to automate a registration for using selenium webdriver. There are no ids or names as such for this button. Hence i tried with xpath (taken from firebug) .//*[#id='load_form']/div/div[2]/input and classname - button.
Yet the following error was being thrown Element is not currently visible and so may not be interacted withCommand duration or timeout: 428 milliseconds.
Please suggest as to how can i ever overcome this error and be able to click on the "submit" button.
Selenium Version - 2.44
I encounter this issue a lot, and one thing that normally solves the problem is switching frames. With python I think it's something like driver.switch_to_frame('frame') I may be wrong there with the syntax but definitely try that out
Try this one:
driver.findElement(By.xpath("//div[#id='load_box']/form[#id='load_form']//input[#class='button' and #type='submit']"))
Problem was that there are several form elements with "load_form" on the site and the first one is hidden! that's why you need a more specific xpath like the one above.
So I think Chrome and Firefox interpretation of DOM is screwing with me. I am trying to print a pdf from a browser (dynamically created) because I can't have the header and footer normally printed with printing an HTML page. Now I was just sending the PDF using fpdf from a php page and use the toolbar or right click and print but now the clients want a button on the page to initiate the print dialog but of course not print anything else but the PDF.... so I embeded it:
<embed
type="application/pdf"
src="print_pdf.php"
id="pdfDocument"
width="100%"
height="100%" />
and a button's onClick called
<script type="text/javascript">
function printDocument(documentId) {
((function(){return document.getElementById(documentId);})()).print();
//Wait until PDF is ready to print
if (typeof document.getElementById(documentId).print == 'undefined') {
setTimeout(function(){printDocument(documentId);}, 1000);
} else {
var x = document.getElementById(documentId);
x.print();
}
}
</script>
where documentID = "pdfDocument"
This worked great in IE9 but chrome and mozilla all say "Uncaught TypeError: Object # has no method 'print'"
so I tried to use thinking embed was causing improper object interpretation in chrome:
<object data="print_pdf.php" type="application/pdf" width="100%" height="100%" id="pdfD2">
alt : test.pdf
and called the same onClick, where documentID = "pdfD2"... "Uncaught TypeError: Object # has no method 'print'"
Then I tried an Iframe:
... "Uncaught TypeError: Object # has no method 'print'"
I'm so frustrated given Chrome is my go to... I even disabled chrome's builtin PDF view and used Adobe 10.xxx.. ARGH!!!
FYI, my simple button tags are:
<input type="button" value="Print Rx" onclick="printDocument('pdfDocument')">
<input type="button" value="Print Rx2" onclick="printDocument('pdfD2')">
<input type="button" value="Print Rx3" onclick="printDocument('pdfD3')">
I think the error is in the line:
((function(){return document.getElementById(documentId);})()).print();
which means that you "pack" (well possibly) uncompleted DOM into the closure.
It goes before the next line which checks for "undefined" print.
Apart from this, why do you use timeout, and not just use onload or DOMReady events?