Not able to click button using selenium Python webdriver - html

I am trying to click on a button on a website using Selenium Webdriver python and I see the button getting highlighted, but not getting clicked using click() function.
Below is the html code for the button I am trying to click
a id="btn_Reset" class="top_btn" onclick="Reset();" href="#">Reboot< /a
I am trying to click on the button using id
inputElement = driver.find_element_by_id("btn_Reset").click()
I also tried xpath with same result
inputElement = driver.find_element_by_xpath("/html/body/div[8]/div/div[2]/div[1]/ul/li[3]/a").click()

Perhaps it's a silly matter of doing it this way:
inputElement = driver.find_element_by_id("btn_Reset")
inputElement.click()

Related

Clicking button with only id (puppeteer)

Im trying to click a button and usually I do it with the class of the button in puppeteer. But this button doesn't have a class how can I click it then? thx for any help :)
I've tried doing this command and tried if it works.
await page.click("[id='submit-label']");

Unable to click Next button on gmail login page using selenium

I am new in automation testing and learning selenium. I was coding for Selenium program for Gmail Login. I am able to hit url and enter username but there is button called "Next" on same page which I am unable to click to go further .I tried clicking same using "xpath".
Below is the html code for that button when I inspected element using FireBug.
<span class="RveJvd" snByac">Next</span>
My code:
WebElement we = driver.findElement(By.id("identifierId")); we.sendKeys("emailid");
driver.findElement(By.xpath("/html/body/div[1]/div[1]/div[2]‌​/div[2]/form/div[2]/‌​div/div[2]/div[1]/di‌​v/content/span]")).c‌​lick();
You can try the following.
WebElement we = driver.findElement(By.id("identifierId"));
we.sendKeys("emailid");
driver.findElement(By.id("identifierNext")).c‌​lick();
after entering id, and for that next use
driver.findElement(By.id("identifierNext")).c‌​lick();
after giving password and then for that next use
driver.findElement(By.id("passwordNext")).c‌​lick();
Try this :
WebElement we = driver.findElement(By.id("identifierId"));
we.sendKeys("emailid");
driver.findElement(By.cssSelector("span[class='RveJvd']")).click();

can't see the HTML of a popup window how to interact with it from selenium

I am trying to select Status form a new windows popup. After clicking the select status button it opens the dialog page but i can't see the HTML of that page. So not sure how to interact with that dialog page from selenium.
NB: I have switched to the new window but can't proceed from there.
HTML looks like this..
After clicking the select Status button following dialog page opens.
but i can see the html of the dialog page so how to interact with it form selenium?
Update -14/09/17
When i click on Select Status it call the below url. Opened the url in a separate tab and was able to see the HTML.
http://xxx.xxx.xxx.int/tasks/status.aspx?CurrFilters=OPEN
Tried to select a values from the new windows like below...
public void SelectStatus()
{
_SelectStatus.Click();
Browser.Switch_to_child_page();
_container.FindElement(By.CssSelector("input[onclick^='SelectAll']")).Click();
}
getting following error.
Test 'x.RegressionSuite.TestCases.xTest.TC_x' failed:
OpenQA.Selenium.StaleElementReferenceException : Element is no longer
valid
It looks like new windows popup. you can switch to new window. then interact with it.
// Store the current window handle
String winHandleBefore = driver.getWindowHandle();
// Perform the click operation that opens new window
// Switch to new window opened
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
//select the checkbox
driver.findElement(By.xpath("xpath for checkbox")).click();
//click on select button
driver.findElement(By.xpath("xpath for submit")).click();
// Close the new window, if that window no more required
driver.close();
// Switch back to original browser (first window)
driver.switchTo().window(winHandleBefore);

vba in html- Need to onmouseup login which is not a button

Is it possible to automate a login page using vba which has a mousedown and mouseup clicks . When i click a login button it has a mousedown click as it doesn't have any button in order to automate using vba.
Please let me know if its possible to do so in vba using some functions
Please copy the URL and paste in internet tab: "http://discovery.ariba.com/rfx/3796429". After clicking the URL you will enter to Ariba Discovery site and there you have this Ship to Service location field. In that ship to service location field there are multiple locations and we need to click on "Show more". To click show more if we see the html code it's not a button in order to automate the click. It's awmouseup and aw is the page name i guess. I would recommend you yo use google chrome and try inspecting the html code. I need to automate the click using VBA code.
ie.document.getElementById("_sbsyf").click
should do it

Anchor tag href attribute incorrect in IE11 during ace editor change event

See the following fiddle: http://jsfiddle.net/R3VbC/4/
In the example fiddle, I run the parseHref function when the ace editor's value changes. This in turn passes a string to an anchor element which is used to normalise the url. You can also click the Parse href button to run this function directly.
var parseHref = function()
var anchorNodeHrefOriginal = urlParsingNode.href;
urlParsingNode.setAttribute("href", 'my-href')
var firstPassHref = urlParsingNode.href;
urlParsingNode.setAttribute("href", firstPassHref)
var finalHref = urlParsingNode.href;
$('#original-href').html(anchorNodeHrefOriginal);
$('#first-pass-href').html(firstPassHref);
$('#final-href').html(finalHref);
}
editor.getSession().on('change', parseHref)
This replicates the functionality used by angularJS to resolve url (see this). This is relevant as I am trying to embed the ace editor in an angular app.
To reproduce the issue I am experiencing, copy and paste some text (do not just type it!) into the editor. In chrome, the values of the text displayed at the bottom should all be something like http://fiddle.jshell.net/R3VbC/4/show/my-href. If you do the same thing in IE11, the values displayed are simply 'my-href'.
If run this parseHref function in any other way, such as typing into the editor or clicking the parse href button, you get the desired result (i.e. http://fiddle.jshell.net/R3VbC/4/show/my-href). It only seems to give the incorrect value if you copy and paste text into the editor.
This could also be worked around by executing the parseHref function from window.setTimeout (see http://jsfiddle.net/R3VbC/5/)
editor.getSession().on('change', function() {
window.setTimeout(parseHref);
})
So it appears that somehow the ace editor is preventing anchor tags from resolving correctly in IE11 during the change event. Why is this happening and can it be prevented?
This ie11 error which happens with textarea too http://jsfiddle.net/R3VbC/6/.
urlParsingNode.setAttribute("href", firstPassHref) doesn't work when called from paste event.
try
textarea.addEventListener("paste", function(){
parseHref()
})
// not very a useful code snippet, but without it
// this `extremely intelligent` site removes jsfiddle link:(
But more importantly you shouldn't do any slow operations, like accessing dom, from change event, use editor 'input' event which is fired with ~30ms timeout, or use your own longer timeout.