I am automating a test on a page and I need to click the "Add images" button. But it's not reacting
<button class="btn btn-default awe-hidden" id="html5button" onclick="$('#html5files').click();return false;">Add images</button>
I have tried
cy.get('button').contains('Add images').click()
cy.get('button').contains('Add images').invoke('show').click()
cy.get('button').contains('Add images').invoke('show').click({force: true})
cy.get('button').contains('Add images').trigger('mouseover').dblclick()
Also tried trigger 'mousedown', short wait then 'mouseup'
Also tried cy.contains('Add images').click()
Any ideas?
The onclick() event handler contains a jQuery expression, but I suspect Cypress doesn't handle it properly.
You can use cypress-real-events instead
cy.get('button').realClick()
Related
I have a simple assertion on a disabled button within my selenium test that fails. The method expects the button to be disabled but when I run the test it fails stating that the button is actually enabled.
I use Ruby/Rspec and this is the code used to check that button is disabled. I've removed the references to the class and page object but the button object locator used is by :id.
expect(Page.btn.enabled?).to be false
Here is the html of the page for the disabled button I am testing:
<input type="submit" name="ctl00$bodyContentPlaceHolder$btnContinueToAddress" value="Next" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$bodyContentPlaceHolder$btnContinueToAddress", "", true, "", "", false, false))" id="ctl00_bodyContentPlaceHolder_btnContinueToAddress" class="btn btn-primary btn-block disabledContent">
I would expect the selenium test to pass as the button IS disabled on the page, but the rspec results show:
expected false
got true
Is the locator used incorrect and the :id is actually enabled? Is there something I'm missing? Thanks in advance.
Unable to click on OK button
I tried like this but it is not clicking.
b.find_element(name: "OK").click #----> it is not clicking
How to interact with this type of pop-us in ruby.
<input class="copybutton" type="button" title="Copy" onclick="copyErrText()" name="copy" value=""/>
<!-- *** Added: copy button *** -->
<button class="button" onclick="disp()" name="OK" value="OK" type="button">OK</button>
You can try one of the following it may help you.
ele = find_element(name: "OK")
driver.action.move_to(ele).click(ele).perform
or
driver.execute_script("arguments[0].click();",ele)
or
driver.execute_script("disp();")
You've tagged this Watir, but your syntax is Selenium. If you are using Watir, it would look like this:
browser.button(name: 'OK').click
If there are funky javascript things going on, you can fire an event to interact with it. Use this power sparingly.
browser.button(name: 'OK').fire_event :click
Hope this helps.
driver.switch_to.alert.accept
So I have been experimenting with Watir automation scripts using Ruby. I have tried to experiment with different websites, like Twitter, Gmail, and Yahoo. Here is the catch: I am able to open a browser, login, and get to the home page. On all of these whether it is compose a new email or tweet every time I select it with the appropriate ID or Class, it throws an error in the terminal like this...
.rvm/gems/ruby-2.2.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:533:in assert_element_found': unable to locate element, using {:title=>"compose", :tag_name=>"button"} (Watir::Exception::UnknownObjectException)
from /Users/xxx/.rvm/gems/ruby-2.2.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:505:inassert_exists'
from /Users/xxx/.rvm/gems/ruby-2.2.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:114:in click'
from yahoo_mail.rb:18:incompose_email'
from yahoo_mail.rb:27:in `'
My question is, are there elements that you simply cannot click or select using Watir automation?
EDIT: How would I be able to hit this to be more specific? I seem to be getting the same results on Yahoo, Gmail, and Twitter when it comes to composing anything after getting logged in. So I how would I hit this button?
button id="global-new-tweet-button" type="button" class="js-global-new-tweet js-tooltip btn primary-btn tweet-btn js-dynamic-tooltip" data-placement="bottom" data-component-term="new_tweet_button">
The HTML for the Compose button is basically the following (NOTE: id attribute removed):
<button tabindex="0" data-action="compose" title="Compose" class="btn btn-compose">
Your stacktrace indicates that you're using this locator:
{:title=>"compose", :tag_name=>"button"}
If you change :title=>"compose" to :title=>"Compose", you should be in business.
Have you tried the following code?
button(id:'global-new-tweet-button').when_present.click
Maybe you were clicking the button without checking if it is already present on the page.
I have a confirmDialog and I need to do some action when the dialog is canceled. I've attached that action to 'close' button, but I need to do that also when user click 'x' icon in the top corner. How to do that?
I've tried ajax listener:
<p:confirmDialog appendToBody="true">
<p:ajax event="close" onstart="myAction()"/>
</p:confirmDialog>
but I've got an error:
Unable to attach to non-ClientBehaviorHolder parent
What you want cannot be done, as in, it's not supported by JSF (not just primefaces).
The <p:confirmDialog/>is not a ClientBehaviourHolder(components that support listening for actions on the client side). You should just disable the X close button, forcing the user to click on either the Yes or No buttons. To disable the X:
<p:confirmDialog id="theDialog" closable="false"/>
Or you could spring for the <p:dialog/>, which provides support for listeners
Further reading:
<f:ajax> Unable to attach <f:ajax> to non-ClientBehaviorHolder parent
So i want my web page to promt for validation on desktop notifications when it loads. So i added onload in body...
<body onload="setAllowNotification() return false;">
This works jsut fine on mozilla firefox but in Google chrome it doesn't show the question. But if i call that function like this, it works.
<a onclick="setAllowNotification(); return false;" href="#">Click to set allow notifications</a>
If it helps my setAllowNotification function:
function setAllowNotification()
{
window.webkitNotifications.requestPermission(permissionGranted);
}
So any ideas?
Try adding a semicolon to your onload event inline code:
Check this answer actually...
Webkit notifications requestPermission function doesn't work
You can only use it as part of a response to a user action - i.e. you cannot do it "onload"