iMacro is not reacting as expected - automation

I'm new to iMacros, I tried to develop one, but struck here.
any help or reference will be much appreciated.
I want to go to Google, then type text, and want to get all the stuff that appears in anchor tag(Link and text)
Here what I got so far.
VERSION BUILD=7500718 RECORDER=FX
TAB T=1
URL GOTO=https://www.google.com/?gws_rd=ssl
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=Blaze
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=NAME:btnG
TAG Pos=1 TYPE=DIV ATTR=CLASS:r EXTRACT=TXT
but if pops up with a box #EANF#, I guess some sort of error or warning.
Thanks

TAG POS={{!LOOP}} TYPE=CITE ATTR=CLASS:"_Rm" EXTRACT=TXT
TAG POS={{!LOOP}} TYPE=H3 ATTR=CLASS:r EXTRACT=TXT
' prompt extracted values or do something else
PROMPT {{!EXTRACT}}
Play the above macro in loop mode when you are already on the ‘google’ page which you want to get content of (i.e. after running first five lines of your code).

Related

Continue Button - Dynamic value

I have 3 registration pages and each page has continue button. I want to use one method for all 3 pages but they have same xpath with different id.
eg
First page xpath: //div[#id='personalInfo']//button[#class='btn btn-primary btn-block'][contains(text(),'Continue')]
Second page xpth: //div[#id='AccountInfo']//button[#class='btn btn-primary btn-block'][contains(text(),'Continue')]
Please let me know how can i use dynamic as I used or for #id but work for first page but in second page it says element not found.
Thanks
I used or for #id but work for first page but in second page it says element not found.
First page xpath: //div[#id='personalInfo']//button[#class='btn btn-primary btn-block'][contains(text(),'Continue')]
Second page xpath: //div[#id='AccountInfo']//button[#class='btn btn-primary btn-block'][contains(text(),'Continue')]
you can use this. It will always click on the button with the text Continue.
driver.findElements(By.tagName("button")).stream().filter(e -> e.getText().equals("Continue")).findFirst().get()
.click();
Option# 1- you can simply look for a button with text - continue if it is unique on your page.
"//button[contains(text(),'Continue')]"
Option# 2: just combine the ids using the OR operator like this,
"//div[#id='preferences' or #id='accountInfo' or #id='personalInfo']//button[contains(text(),'Continue')]"

Unable to retrieve the text inside the div tag even when the tag is identified

I am trying to retrieve the text embedded inside the div tag. Partial html code is given below. I consulted the other existing answers, but the tag is located successfully but the text is coming back as empty string.My purpose is to retrieve the string between the 'div' tag as "You entered an invalid username or password, please try again."
I used the xpath
//div[#class='login-card js-login-card']/div[#role='alert']/div[2]
I used the css
.alert__heading.js-alert--error-text
This only getting back the tag name as div, but the text as an empty string.
Any ideas or corrections?
<div class="login-card js-login-card">
<div class="login-page__alert alert alert--error tt js-alert--error" role="alert">
<div class="alert__icon">
<div class="alert__heading js-alert--error-text">You entered an invalid username or password, please try again. </div>
</div>
<div id="cmePageWrapper" class="page-wrapper page-wrapper--card"> </div>
Try following xpath, as the required div tag is child node of div with class 'alert__icon':
//div[#class='login-card js-login-card']/div[#role='alert']/div[1]/div
Let me know, if it works for you.
Maybe you wanna try this
div[class*="error-text"]
If it didn't work try to get text by executing javascript code using this
$$( "div[class*="error-text"]" ).text() OR .val()/.html()
Good luck !
You could use contains with xpath, something like //div[contains(#class, 'error-text' ) ], using findelement will retrieve first element match the criteria. If it still returns empty, it means that the page might have more than one element which match the criteria

Runtime error imacros script blocking y loop

Using Imacros on tumblr I'm getting this error each time the save button has been pressed
RuntimeError: Error loading page about:blank, line 7 (Error code: -933)
This is the imacros script
TAB T=1
TAG POS=1 TYPE=I ATTR=CLASS:icon_post_photo&&TXT:
TAG POS=1 TYPE=INPUT:FILE FORM=ID:edit_post ATTR=NAME:images[o1] CONTENT=C:\sampleimage.jpg
TAG POS=1 TYPE=A ATTR=TXT:Set<SP>a<SP>click-through<SP>link
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:edit_post ATTR=ID:post_three CONTENT=http://www.website.com/
TAG POS=1 TYPE=SELECT FORM=ID:edit_post ATTR=ID:post_state CONTENT=%2
TAG POS=1 TYPE=BUTTON FORM=ID:edit_post ATTR=ID:save_button
the post get posted but it stops my loop.
Anyone got an idea on what could it possibly be?

How to check if a text is in web page in Robot Framework and Selenium

I'm currently creating an automation test for a website and I want to check if a text(s) is in the page. I could use the keyword 'Page should contain' to check; however, I want it to be a little more specific on having it check specifically where the text exist in the page. Is there a way I can have it check if a specific div contains the text?
You can easily do this with a built-in Selenium2Library tags.
For a partial match use this:
Element Should Contain locator expected_text
For an exact match use this:
Element Text Should Be locator expected_text
If your HTML code is something like:
Your div tag and need to find FindMe
<div class="gwt-Label">This FindMe DIV</div>
Then you can find "FindMe" text like:
//div[#class='gwt-Label'][contains(string(),'FindMe')]

placeholder input field not showing value?

I have an input box with placeholder.and I am setting the value in this field via Session variable in php.
This is the code which I have written :
<input type="text" value=<?=$_SESSION['no_of_persons']?> name="no_of_persons" id="no_of_persons" placeholder="No. of Person(s)" maxlength="3" />
and when I run this in firefox and watching the code in Firebug this following code is coming :
<input id="no_of_persons" type="text" maxlength="3" placeholder="No. of Person(s)" name="no_of_persons" value="7">
Problem is I am not able to see the value in textfield in the web page.
I go to firebug and edit html in firebug. What I do is when I press an space key at the end of input tag i.e after value="7" then the value 7 becomes visible on web page.
I am not getting why the browser automatically changing the sequence of attributes of input tag and also I already had closed input tag then why the browser not closing it.
I tried it in other browser also like safari,chrome but not working.
Please help me to get rid off this problem.
Thanks in advance!!! :)