I looked around, but I wasn't able to find anything that answered the question that I have at hand. I want to click a button with Selenium, but the button ID is dynamic (meaning it changes after EACH button press). I would like to click the button via it's value, but with Selenium IDE, the Firefox extension, I'm not positive how I could go about this. Here's the coding of the button that I'm trying to click, with Selenium.
<input id="move247957048" type="button" style="width: 120px" value="Sacred Sword">
The input id="move" that you see, it changes every single time I click this button. All of it changes except for the first digit, the 2. With Selenium, I have no clue whatsoever about how I could click this button via it's value, or whatever would work. D: It's repetitive as well, so it'd handle it multiple times.
In Selenium IDE you can use xpath defined locators, in your case I would use next xpath //input[#value='Sacred Sword']. You can find it in related documentation http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#test-case-pane
Related
I'm trying to click on a button on a page that has a lot of JavaScript but no matter what I try, can't click it. Is there a way for me to click the button manually and get what I need to click?
I've tried inspecting elements and FirePath but those aren't giving me the correct class or id that I need to click
Edit: This is what I'm trying to accomplish, the below is from Selenium IDE firefox plugin
Command Target
open /logger/summary.ftl
clickAndWait link=System Admin
selectFrame sysadmin-content
click //div[#id='sysadminmenu__sysadminmenu_x-auto-29']/span[3]/span
click id=x-auto-178
You may try
http://www.seleniumhq.org/projects/ide/
This has a feature to find web element path
I have a question that is a little outside my realm. I'm a newbie to jquery and javascript. I run a forum on ProBoards, and when the forum runs out of its allocation for attachments (pictures the users can post) I have to manually go through the attachment list and check every single checkbox one by one, then I am able to click a delete button to delete every attachment I've checked. Checking the thousands of boxes one by one takes forever. There is no implemented "check all", and there are thousands of checkboxes.
In the code, every single checkbox has the name ids[]:
<input type="checkbox" value="1494" name="ids[]"></input>
So I should be able to target them by the name "ids[]" I would think. The value is different for each one. The name is the same for all. But the question is... what code would I use and where would I put it in Firebug or Inspector? I'm sadly too much of a noob to be able to figure out what I would do.
I have Firebug for Firefox, and in that I have the add-on jQuerify, so I can force jQuery into the code if that helps create the simplest solution.
Basically I'm looking for a way to add some code to automatically check every single one of these boxes (or add a button that will allow me to do so if that is the only way), and I must be able to do it from Firebug or the Inspector in Firefox (or even in Chrome would be fine). I don't think I am able to modify the code (permanently) of this specific administrative page of my forum, so I need to be able to do it from the Inspector/Firebug. I'd like something I can just copy and paste into there to save myself 45 minutes to an hour of clicking thousands of checkboxes one by one.
Any solutions?
Use like this,
$("input:checkbox").attr('checked','checked');
You should be able to use the following in the console:
$('[name="ids[]"]').prop('checked',true)
Using Inspector Console F12 you can get all checkbox and check them
$('input:checkbox').prop('checked', 'checked');
I need to sort messages, and I can either remove them or approve them (or ignore).
I want to create a script (probably using Tampermonkey - I'm using Chrome on mac) where I could input a list of recurring words (swear words I would input) for which it removes the messages so that it can go faster, it would automatically click the remove button after if it find the word(s) in the message.
If it doesn't find anything I want it to do NOTHING, just leave the page as is.
Basically usually after I click the button the page loads again automatically and gives me the next message.
I don't really know programming, I'm mostly just around html/css and a bit of jquery, but I'm learning here and there.
How can I achieve this ?
Thank you very much.
I am developing a desktop application in Delphi XE4 using TChromium component to display Google Voice webpage.
I need to start a call programmatically and I can't find a way to trigger the javascript code behind the button (it is a DIV) "CONNECT":
TChromium allows to execute javascript code and I already managed to simulate the click on "CALL" button using a javascript code that simulates the Key Event using the character "c" which display the panel. This works because Google Voice has shortcuts and "c" is a valid shortcut to start a call. Also with javascript I can set the number in the input field. My main problem is that I don't know how to simulate a click on "CONNECT":
As you can see, there is no ID, no onClick and there is no shortcut to trigger the Connect button.
I can get a reference to this DIV using the following code:
document.getElementById(":87.mi").children[0].children[0].children[5].children[1].children[0].children[0].children[0].children[1];
But it is not possible to trigger anything appending .click(). I assume it is because click() will trigger onClick method that it is not defined. Is there any way to know what javascript code executes when someone clicks over this div?
If the focus is in the "Number to call" input, I can press "TAB" to navigate to "Phone to call with", then to "Remember to choice" and finally to "Connect" where I can press Enter key to make it work also. I tried to use the same code as in the beginning to simulate the CALL button but this time with TAB (keycode 9 instead of 67) and it does not work as the focus does not move.
I tried to do it programmatically with delphi also using mouse_event, keybd_event, PostKeyExHWND, PostKeyEx32 and PostMessage with no results as the focus does not move away from "Number to call"
The only option that works by now is to move the mouse with delphi using SetCursorPos and simulate a click on that button calculating the coordinates but this will be my last option to choose as I would prefer a javascript code to do it.
Any suggestions are welcome!
I suggest the next solution.
In a javascript file that have to be imported from the view, put the next code:
$(".goog-button-base-content").click(function(){
//CODE HERE
});
What you do here is that everytime that we pressed the div that has that class, you will start the logic inside "CODE HERE"
(Sorry for my bad english)
I hope be usefully. See you
Trying to automate certain tests dealing with Yammer. What I want to do is to use selenium to post something, but when I click on the textbox it changes it's id. Also, everytime the page reloads, or a post is made, that textbox changes it's id.
So what I did next was to use wildcards by telling selenium to look for
//input[starts-with(id, 'yamjs')]
However, I quickly found out that yamjs is used for both the body of the update as well as the "+ Add people to notify" textbox.
The difference between the two seems to be the class. The one that we're interested in has a class="yj-tapf-textarea" whereas the add people to notify textbox has a class="yj-callout-bar-entry-field"
How do I get selenium to find the input field with the id that starts with yamjs within the class yj-tapf-textarea, and not the one in the class yj-callout-bar-entry-field?
Seems like I wasn't paying close enough attention to the classes and their locations. Here's what I ended up with:
driver.findElement(By.className("yj-auto-width-fake-textarea")).click();
driver.findElement(By.className("yj-tapf-textarea")).sendKeys(Text);
driver.findElement(By.id("yj-yam.ui.publisher.old.SubmitButton")).click();
If the id changes then perhaps it is a hint to not use id as the locator.
Using CssSelectors and XPath can give you more stable and reliable locators