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
Related
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()
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 want to upload a gif file in my application using selenium codes in firefox,
i have the following file input type:
<input id="file" type="file" size="27" value="Attach document" onclick="javascript:return processAttachment();" name="file">
i have tried this code:
driver.findElementByName("file").sendKeys("E:/plus.GIF");
driver.findElementByName("file").click();
but its is not working, instead a file upload window is opening, can any one help me getting out of it.please
thank you
With this line driver.findElementByName("file").click(); you are "trying" to click the field , where you typed the text.It should be driver.findElementByName("NAME OF THE SUBMIT BUTTON").click();
So I have a method that implements IHttpHandler.ProcessRequest. It accepts an HttpContext parameter. This parameter is just a form that is filled out with some XML. Here is the HTML that I am using to generate the post context:
<html>
<body>
<form name="form1" method="post" action="http://localhost:7703/api.ashx">
<textarea name="XML" id="XML" rows="25" cols="100"></textarea>
<br/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
As you can see, very simple. This is just used for testing purposes. What I am doing is posting XML in that textbox, and hitting submit. However, I am not sure what to attach my visual studio project to in order to debug. I try attaching it to w3wp.exe like I do when I test the app in a browser and stuff, but that doesn't seem to be working. It still says "This breakpoint will never be hit, no symbols loaded..." blah blah blah, when I put a breakpoint next to the ProcessRequest method and attach.
How do I test this properly?
Thanks guys.
If you run this locally you should be able to "run" it from within Visual Studio and VS will automatically attach it self to the correct process.
If I attach to the development server at the same port as the post, it works! :)
I have tried a number of things to try and get Selenium to pick up an 'onchange' event from a drop down menu, none of which has worked.
The offending HTML is:
<select onchange="doOpperation(this.options[this.selectedIndex]); this.selectedIndex = 0;" name="opps_ondemand" id="opps_ondemand">
<option value="none" id="ondemand">Mark as...</option>
<option cmd="blah1" value="add">Something</option>
<option cmd="blah2" value="remove">None</option>
</select>
I have read that Selenium IDE doesn't record some on* events, and so it would be wise to use fireEvent():
$this->click("opps_ondemand");
$this->select("opps_ondemand", "label=Mark as...");
$this->click("//option[#value='add']");
sleep(3);
$this->fireEvent("//select[#id='opps_ondemand']", "change");
However, this does not work (with or without the fireEvent). I have also tried using
$this->fireEvent("locator", "click");
instead of
$this->click("locator");
but this did nothing.
Selenium does not complain about these locators not existing so I am assuming it can see the select/option elements fine. The problem seems to be the onChange event.
Does anyone know how to resolve this?
Thanks.
I encountered exactly this problem, but in IE only (Firefox and Google Chrome works fine for me)
I found the solution to be manually forcing the update using JavaScript through Selenium's runScript. Some ways to do that can be found here:
How do I programmatically force an onchange event on an input?
For example, if I have jQuery in my Web page, I would do this:
$this->select('IDOfSelectElement', '*some label*');
$this->runScript("$('#IDOfSelectElement').trigger('change')");
tried this?
$this->fireEvent("opps_ondemand", "onchange");
fireEvent(element_id, event_to_trigger);