Runtime error imacros script blocking y loop - scripting

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?

Related

selenium code for accessing button type submit in c#

I am trying to extract the text in an input box,
<input value="Add a Phone" onclick="CSS.addClass($("u_0_4"), "async_saving"); new AsyncRequest().setURI("\/ajax\/phone\/confirmation").setData({source: "www_mobile_settings"}).setStatusElement($("u_0_4")).send();" type="submit" id="u_0_5">
I have tried for ;
driver.FindElement(By.Id("u_0_5")).Click()
but raising an error of : No such element Unable to locate Element
The element Add a Phone is present inside an iframe.You need to switch the iframe first in order to access the element.
driver.SwitchTo().Frame(driver.FindElement(By.CssSelector("iframe[src^='https://www.facebook.com/settings?']")));
driver.FindElement(By.CssSelector("input[value='Add a Phone']")).Click();
In order to get that button, you can use CSS selector here is one
driver.FindElement(By.CssSelector("input[type='submit'][value='Add a Phone']")).Click()
or by XPATH
driver.FindElement(By.XPath("//input[contains(#value,'Add a Phone')]")).Click()

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')]"

Click on a specific part of HTML element

I have a checkbox element on my web-page which has a partial link which reads as Read the conduct risk manual where in conduct risk manual is a link which when clicked on navigates to page that has conduct risk manual listed down.
The HTML structure for this element is as below:
<div class="checkbox">
<label>
<input ng-disabled="readonly" type="checkbox" name="policyRead" required="" ng-model="confirmOa.confirmation.policyRead" class="ng-pristine ng-untouched ng-invalid ng-invalid-required xh-highlight">
<span>Read the <a target="_blank" href="http://somesite.xyz/Conduct%Risk%Manual.pdf">Conduct Risk Manual</a></span>
</label>
</div>
Now I want to click on a check-box which used to work if I click on span element but now even if I try with below combinations of web-driver is still clicking on link Conduct Risk Manual
1) .//div/label/input[#name='policyRead']
2) .//input[#name='policyRead' and #type='checkbox']
3) .//span[contains(text(),'Read the')]
4) .//span[contains(text(),'Read')]
5) .//input[#name='startDateConfirmed']//preceding::span[1]
In the 5th xpath I have tried clicking on span element using the following HTML element which is correctly identified and clicked.
I have tried many combinations apart from those mentioned above and all the xpath's correctly highlight the expected element which means it is correctly identified. But still web-driver clicks on Conduct Risk Manual link and navigates to a new page instead of clicking corresponding checkbox.
Can we make web-driver click on a specific part of an element?
Please check xpath's wherein I have already tried using only 'Read' or 'Read the' portion of span element.
Try this below code.
Explanation: Use text method with span tag, then move ahead with preceding-sibling keyword to find input tag for clicking the checkbox element.
Note: span tag use here for reference to get the check-box element text.
WebElement checkbox = driver.findElement(By.xpath("//span[contains(text(),'Read the')]//preceding-sibling::input[#name='policyRead']"));
if(!checkbox.isSelected()) // if checkbox is not selected, then only if is condition will execute.
{
checkbox.click();
}
OR
Using Java-script executor to click the checkbox web-element.
WebElement checkbox = driver.findElement(By.xpath("//span[contains(text(),'Read the')]//preceding-sibling::input[#name='policyRead']"));
((JavascriptExecutor) driver).executeScript("arguments[0].click();", checkbox);
You can try with this code also as a tag is coming over to the checkbox.
WebElement checkBox= driver.findElement(By.xpath("//span[contains(text(),'Read the')]//preceding-sibling::input[#type='checkbox']"));
Actions action = new Actions(driver);
action.moveToElement(checkBox).click().build().perform();`
Also add import org.openqa.selenium.interactions.Actions; .

iMacro is not reacting as expected

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).

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!!! :)