jsfiddle click code not responding - jsfiddle

I can't get this fiddle to work
https://jsfiddle.net/mtgna/rwhu14ot/
enter code here
I have tried changing the javascript load method to no wrap(Head) as per
jsfiddle question
but it's still not working.

Does this work?
<button class="myButton" onclick="sniffles.talk()">
This line doesn't seem to do what you want it to do.
$('button.myButton').click(sniffles.talk())

Related

How can I access a button to click it with following code in selenium webdriver?

There are many buttons sharing the same class.
May have to go with clicking the link /account/logout'.
This is the code I'm trying to use:
input class="btnRed text-uppercase fo_white" value="Logout" onclick="window.location.href='/account/logout';" type="button"
Hard to say because you didn't provide enough info, but you could probably make it work by using value attribute. Something like this if you are using java.
driver.findElement(By.cssSelector("[value='Logout']")).click();
Not pretty solution, but give it a try:
driver.findElement(By.cssSelector(".btnRed.text-uppercase.fo_white")).click();
Looking at your HTML DOM this command will work for you:
driver.findElement(By.xpath("//input[#value='Logout']")).click();
Let me know if it works for you.
Looking at your HTML, this should work
driver.findElement(By.xpath("//input[#value='Logout'][#type='button']")).click();
Let me know if it works.
Is your element visible/enabled? In order to select an element, it must be present in your DOM. If the element is activated through an event, it cannot be selected until the event occurs.
Take a look at this post. This other post also have good ideas.

Xpath is not working for the following button

Following is the xpath which is not working:
driver.findElement(By.xpath("html/body/div[10]/div[2]/div/div[5]/div[3]/button")).click();
The image shows the button which is not working
Why not Try CSS Selectors.
driver.findElement(By.CssSelector(".btn"));
Try this:-
//div[#class='text-right btns imme_result_btns']/button[#type='button']
If it didn't work then please share your HTML code in question so we can help you better
Hope it will help you :)
get back to me if still facing any issue :)

Protractor When sendKeys meet issue 'cannot focus element'

I am not sure if Protractor can sendKeys to a div.
My code is
element(by.css('.create-api-schema-editor .CodeMirror .CodeMirror-lines .CodeMirror-code .CodeMirror-line')).sendKeys(content);
I also tried click first and then sendKeys, but no luck.
HTML is:
enter image description here
I fixed the issue, we can use browser.actions().click().perform() instead of ele.click().
I am not sure why but it works.
Hope this helpful for you.

click on submit button not working in selenium webdriver

I trying to click on the create account button in registration form.
this is how the button locate in the html page:
<div id="submitContainer"><button type="submit" class="large"><span><strong> Create Account </strong></span></button></div>
this is the button xpath:
//*[#id="submitContainer"]/button/span/strong
the problem is that the button don't have id, he locate inside a div.
I try to use by id,xpath,css,name, but all of this not working:
driver.findElement(By.id("submitContainer")).click();
driver.findElement(By.xpath("//*[#id='submitContainer']/button/span/strong")).click();
driver.findElement(By.tagName("Create Account")).click();
driver.findElement(By.className("large")).click();
thanks!
In your examples, except for the last one, you are not targeting the button. Now your last example, should actually locate the button-element:
driver.findElement(By.className("large")).click();
Could you please post the error message you are getting?
Are there more than one element on the page with className "large"?
Make sure the button is in view window, if it is then try clicking on it. Try to wait for the element to load. There might be an issue with your element being loaded into DOM -
driver.wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//button[#type='submit']"))).click();
Hope this helps.
If you want to use xpath, the correct syntax is
//button[#type='submit']
Use this line below:
Thread.sleep(3000);
I got the result once I used this one. Since some time we need to give some sleep time for the site to load fully to pull the Xpath.
You can use the linkText
driver.findElement(By.linkText("Create Account")).click();
Hope it will work for you.

click # checkbox is done but not registered

I`m relatively new to Selenium and trying to create some test cases with the Selenium IDE.
I just selected a checkbox with XPath with the following command xpath=//input[starts-with(#id,'003g')].
After the checkbox is selected, I click another button to add the value from the checkbox.
But nothing happens. The application always tells me that no record is selected... If I push the play button I can see IT IS selected.
What to do?
Thank you guys!
edit:
At first... Thanks for your help!
I don`t think, the problem is caused due the fact that the element is not present. I can see that Selenium selects the according data record (checkbox)
Here is some code. I hope it will help! In fact I am new to this whole webstuff and have no clue about web techniques.
<td class="x-grid3-col x-grid3-cell x-grid3-td-checkbox x-grid3-cell-first
"tabindex="0" style="width:18px;">
<div id="003g0000006ElPO_checkbox" class="x-grid3-cell-inner x-grid3-col-checkbox">
<input id="003g0000006ElPO" class="checkbox" type="checkbox" name="ids" title="<a
href="/003g0000006ElPO">
<span>JeanneSeleniumOne</span></a>" value="003g0000006ElPO">
There's too little information to help, but a wild-guess would be the element wasn't ready to be clicked i.e. you should wait for some time before clicking.
I just posted a similar answer here