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()
Related
I have a script written and have been able to code for buttons that have html but this button that I inspected on this link, doesn't have one.
This is the element for the login button.
<input type="submit" value="login" class="button">
How would I write this line of script to click on this button using selenium & python?
To click on the button with text as Login you can use the following line of code :
browser.find_element_by_xpath("//form[#method='post' and #action='/auth/login/']//input[#class='button' and #value='login']").click()
#or
browser.find_element_by_xpath("//form[#method='post' and #action='/auth/login/']//input[#class='button' and #value='login']").submit()
your element has few attributes, which we can use. Try to find an element which starts with input and has an attribute type='submit'
driver.find_element_by_xpath("//div[#class='content']//input[#type='submit']").click()
Im creating a automation using VB in microsoft Visual Studio like a app
the project path is Visual Basic>windows classic Desktop>windows form
app(.NET framework).
Code is written using VBA and it is a form which gets
user input and paste it into a webform and click a submit button and create a Ticket.
I already have this automation running via VBA excel. however due to some circumstances i need to create it as a standalone app instead. I have problem in clicking the submit button. can someone please assist me in putting the code right.
this is the HTML element taken from view source
<input type="hidden" name="ticket_type" id="ticket_type" value="" />
<input type="hidden" name="quicklink_id" id="quicklink_id"value="0"/>
<textarea name="work_log" style="display:none"></textarea>
<textarea name="correspondence" style="display:none"></textarea>
<div id="action_bar" class="cti-search-enabled">
<div id="button_bar">
<a class="tt_button orange_button" href="#" onclick="ajax_submit()">
<span>Submit Ticket</span></a>
<a class="tt_button" href="#" onclick="build_quicklink()">
<span>Save as New Quicklink</span></a>
as you can see there are two buttons, one is Submit Ticket and Save as New Quicklink. i need to click the Submit Ticket button. The earlier code is used in VBA is
Call sel.executeScript("ajax_submit()", "javascript")
This is my code in .net
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
Handles WebBrowser1.DocumentCompleted
MessageBox.Show("Document loading completed!")
Me.WebBrowser1.Document.ExecCommand("ajax_submit()", "javascript")
End Sub
so once the form is loaded, it will show a message box and then should click the submit button. however this is showing error as
Severity Code Description Project File Line Suppression State
Error BC30455 Argument not specified for parameter 'value' of 'Public Overloads Sub ExecCommand(command As String, showUI As Boolean, value As Object)'. My_First
Can someone help me on how the code should be. Sorry im a beginner in .net (and VBA as well)
This seems to do the trick:
Me.WebBrowser1.Document.All("ID-Of-The-Button").InvokeMember("Click")
Provide me the javascript which I could run in the console window such that it clicks on the button automatically.
<button value="1" class="button_confirm" type="submit">Confirm</button>
Give some id to button, for example button1 and then run the code below in console :
document.getElementById("button1").click();
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'))
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>