How do I factor imacro script? - refactoring

I would like to factor code on imacro, my macro looks like that
URL GOTO=https://www.exempleurl1.com/
CLICK X=273 Y=503
CLICK X=276 Y=548
CLICK X=863 Y=320
URL GOTO=https://www.exempleurl2.com/
TAG POS=1 TYPE=TEXTAREA ATTR=NAME:body CONTENT="Hello"
CLICK X=273 Y=503
CLICK X=276 Y=548
CLICK X=863 Y=320
Over and over again (20 times)
I would like to use a function to automate all the "CLICKS".
Is there any way to factor my imacro code to make it a lot cleaner ?
Thanks

Related

iFrame tabbing within frame/pop-up window

As shown in the following example, I would like to restrict the tab key behavior to just this frame with links.
http://jsfiddle.net/zFXNM/
tabindex ="1"
I do NOT want the tab to go the URL other items in the browser.
For example, the "Compose Mail" in Gmail does this already. I observed 3 usages of "tabindex=-1" within the JS.
In pure JavaScript, I have figured out a solution for this issue. The idea is whenever the page is loaded we determine the first and last links, then we prevent the tab default action and jump to the first link from the last tab.
if (activeElement.id == lastHrefID) {
e.preventDefault();
document.getElementById(firstHrefID).focus();
}
A working solution is available at : https://jsfiddle.net/srirammac/95sv63s7/

How to click a plain button on a webpage using VBScript?

I have a button on an website like this
<button>
Like
</button>
Does anyone know how to find and click this button using VBScript?
Since he have no ID or other things I don't know how to find the button.
So it seems that I am answering my own questions. The more you search, the fastest you learn.
Set Butlike = IE.Document.getElementsByTagName("button")
if btn.textContent= "Like" then
btn.Click()
End if

how open url with click on one div in Watin automation

how open url with click on one div in Watin automation
i am going to url by this code
browser.GoTo(address);
browser.WaitForComplete();
and click on a div like this
var main_tab1 = browser.Div(Find.ByText("main_tab"));
main_tab1.click();
i want when browser going to url the div be cliked
and no need to click ... and the automation will be faster
I am not sure if I have understood your question right. You are asking whether you need to navigate to page on click on Div using browser.Goto(address)? If so, try to navigate directly to the address. Capture the URL when u click on the div and send it to GOTO method.
i click on a button
var repbtn = browser.Button(Find.ById("btnReply"));
repbtn.Click();
and goto a page after click on btnReply
and in this page i have 4 tabs that i must click on one of theme
in this page i capture url with this code
string rep_url=browser.Url;
browser.Goto(rep_url);
and when i click on one of 4 tabs the url not changed that i captured its url
var main_tab = browser3.Div(Find.ByText("main"));
main_tab.Click();
the main_tab Div have onclick method , do i run this method even url loading .

My Asp.Net Form data is not being submitted properly by Selenium 2 (Webdriver)

So I have written a test which populates a form, saves (in the admin tool), and then publishes.
However, my form is being lost between the save click and the publish click. I would show what the form looks like in HTML, but its pretty huge (like 20-30 fields)
In psuedo code, filling out the form looks like this:
1) Fill in form using dropdowns
2) Hit the save button - saves all form data
3) Hit the publish button
When I pause the script to see what is happening within selenium, I see the form properly being populated. I then see the Save button properly being clicked. When I pause the screen before hitting publish, I see that the content I have saved after clicking the save button was lost or is in the wrong fields.
When I do this manually, it works correctly. I know selenium submits forms differently than the standard user, however, is there anything I can do on my end to make sure that form is being submitted properly?
What does the Save button actually do? Is it Javascript, or a simple ` button?
Are you using the C# interface to Selenium webdriver? You probably have code that looks something like this:
FillInForm();
selenium.click(By.CssSelector("input[value='Save']"));
selenium.click(By.CssSelector("input[value='Publish']"));
Have you tried inserting, between save and publish, lines like the following:
// further up: By saveButton = ...
// By formField = ...
selenium.click(saveButton);
var formField = selenium.FindElement(formField);
Assert.That(formField.GetAttribute("value")
.contains("The text you typed into the form")
);
The point here being to check that save really is doing what it says on the tin. Generally, when you ask the WebDriver to "click" on a button, it does do exactly (more or less) what the user does. Alternatively, you can inject some javascript to force the form to submit - but then you're explicitly not testing what the user actually does (but you might find it's closer to what you experience).

selenium is able to find but unable to click on an unicode character

I am having trouble getting selenium RC to click on a button. There is a button on a page that has the character "pi" on it and I am trying to click on it. The html code looks something like this
<div id="abc">
<a class="my keys one" keystring="Pi" keyvalue="π"
π
</a>
</div>
This is what I have done so far -
selenium.click("//div[#id='abc']/a[1]");
This returns an OK but on the page, when I see visually, the button is not clicked (on click, the page has to do something).
I have tried other stuff like getting the Attribute and making it click on it, but doesnt work-
selenium.click(selenium.getAttribute("//div[#id='abc']/a[1]#keystring"));
I have even tried converting the above selenium.getAttribute to a unicode value and then clicking on it. That does not work too.
Also, I added a line to check if at least selenium thinks the character pi is present on the page. I used the unicode of pi-
selenium.isElementPresent("\u03c0");
On eclipse, when I run it, this shows up- isElementPresent[?, ] on session...
and returns a false.
I am stumped. Can anyone please point to me what is it that I am doing wrong?
i thin this may help you.
selenium.click("//a[#class='my keys one']");
or
selenium.click("xpath=//a[#class='my keys one'"]");
if it is not workin use css path.
I a similar issue. My button has a "black down-pointing triangle" on it and none of the other attributes are unique (the "class", "id", and "role" are reused over and over on the same page). The only unique thing I have is a "value" that is a symbol.
value="▼ "
I, too, would like to know if there is a way to click on this button.

Resources