iMacros if a tag is a empty value, set it to a default value - imacros

I am new to Imacros and simply trying to complete a textbox with a default value if it is empty. If it is not empty, then the code will ignore the fill.
Can anybody help me how to make this?
Basically what I need is:
If the textbox named PHONE is empty, then fill it with 555-2828
If it has a phone already, then ignore the fill.

Related

How to check if field on desktop application is empty or filled, and if it's filled mark as exception, and if it's empty proceed?

I am new to UI path and am trying to build a workflow/sequence to check if a field in my desktop application is filled or not.
If the field is empty then I want to proceed with the process, and if it is filled I want it to be marked as an exception.
I currently have it so the flow goes as follows:
1. Identified element
2. used Text Exists activity for that field, and I inputed "" as the Text
What are the next steps?
It would be better if you used Get Text command, and using if condition, check if the text is null or empty and take action.
First you want to use Get text on the Text box to extract its contents and store this in a variable in UiPath (Note: if you create the variable from the side properties panel it will give it the type GenericValue, you'll want to change this to String)
Next depends an what you mean by filled:
If you want to accept spaces as been filled then you can use String.IsNullOrEmpty(YOUR_VARIABLE)
If you want the filed to be filled with characters that aren't spaces you can use
String.IsNullOrWhiteSpace(YOUR_VARIABLE)
for your exception it will depend on weather you want to throw it as an
Application exception (new System.Exception("EXCEPTION MESSAGE"))
or
Businessexception (new UiPath.Core.BusinessRuleException("EXCEPTION MESSAGE"))
So your workflow will want to look something like this

Display one value and return another in text field with autocomplete Oracel Apex 5

I want to be able to have a text field with autocomplete in Apex 5 that displays a client name, city and state, but just returns that client's client_id from the table.
I'm currently using a popup LOV
Is something like this even possible? I've been digging around for hours for a way to make it happen.
There are plugins out there that accomplish this, but I haven't personally used them.
Here's what I've done:
Add a hidden item
Create a dynamic action to parse the autocomplete item and set the hidden item equal to this value.
Create a validation to ensure that the hidden item's value meets your expectations.

How to put formula in Data Validation List Excel?

I am creating an excel sheet with following Data Validation drop down list.
NA
Done
(add some formula here)
Basically, i will be able to select either plain text "NA"/ "Done" from the dropdown list. But sometimes, I want the user to be able to calculate some values based on the cell respective to the row selected so, I want to have one formula as a choice inside the data validation dropdown list. Is this possible?
Data Validation List Source
When I click on Formulae option, it should execute the formula with respect to the cells in that Row
But currently, the formula that i put in doesn't execute, instead it will just show the whole formula in the cell when activated.
1)How can i make it so that when i select the formula from data validation list, it will execute it instead of filling up the cell with it?
2)How do i set the formula so that it will be using the cell from the current Row? (for example, if i am using the data validation List in N60, the formula should adapt itself to use the cell (let's say A60?).
I may not be able to help with the second part, but I was seeking an answer to the first and discovered a solution/workaround using Name Manager.
First, in Formula > Name Manager, create a new reference (the "refers to" will contain whatever formula you are wishing to ultimately display in the validation list. For this example, we use the formula reference "=IF($H54=..." and Name it "UniqueName"
Now, we go into Data Validation, Select List, and input the three items we want displayed in the list, with an equals sign preceding our newly named reference: ie. "NA,Done,=UniqueName"
Note: You can't start with the =UniqueName or validation will try to read it all as a formula and fail.
This method will allow the user to display "NA", "Done", or "=UniqueName" in the cell; if "=UniqueName" is selected, the cell itself will interpret this as a formula and execute it accordingly, displaying the results of "=IF($H54=...", or whateverelse you have designated to use as a named formula.
If it's too late for yours, I hope this helps someone else who may face a similar problem.
While I think I know what you're trying to say. Why don't you just use an IF formula to evaluate everything instead of selecting a drop down for every row manually. You already had it partially solved using IF. Just need to add the criteria for a "Done" and an "NA"
=if(A1="date","Done",if(A1<"date","NA",if(something else until you have all your catergories))
Just going to piggyback off of Mark's response.
If you really needed your named formula to be the first selection in the list, you can setup your list with a leading comma like so:
,=UniqueName,NA,Done
That worked out for my use, and there was no null item listed in the Data Validation drop down. Hope that helps!

Setting selection by text in CComboBox (MFC)

I have a CComboBox of type DropList (i.e. it's not editable). What's the easiest way to set the current selection by string?
I know I can use SetCurSel() to set it by index, but I want the function to search through the list-items by string and set it.
You can call FindStringExact() to obtain the index of the string you want to select, then pass that index to SetCurSel():
yourComboBox.SetCurSel(yourComboBox.FindStringExact(0, yourString));
Note that is the string is not found in the combobox, -1 will be passed to SetCurSel(), which will result in any previous selection being cleared. You may want to perform an explicit test if that behavior does not suit you.
Note that Max's answer should be preferred for new developments. However, SelectString() is only supported from Windows Server 2003 onwards, so you may not be able to leverage it, depending on the platforms you want to support.
What about CComboBox::SelectString ?
"Searches for a string in the list box of a combo box, and if the string is found, selects the string in the list box and copies it to the edit control."
https://msdn.microsoft.com/en-us/library/30ft9e54(v=vs.110).aspx

Writing value on the current textbox - Selenium

Well I'm facing an issue here:
I use Selenium to automate test on my application, and I use the following code to fill a textbox:
driver.find_element_by_id("form_widget_serial_number").send_keys("example", u'\u0009')
All the textboxes have the same id (form_widget_serial_number) so it's impossible to select a specific textbox by using selection by id (the code above selects the first textbox and u'\u0009' changes the cursor position to the next textbox).
Anyway, how can I send values to the "current" textbox without using find_element_by_id or another selector, given that the cursor is in the current textbox?
There are several selectors available to you - Xpath and css in particular are very powerful.
Xpath can even select by the text of an element and then access its second sibling1:
elem = driver.find_element(:xpath, "//div[contains(text(), 'match this text')]/following-sibling::*[2]")
If you need to find the current element that has focus:
focused_elem = driver.switch_to.active_element
And then to find the next one:
elem_sibling = focused_elem.find_element(:xpath, "following-sibling::*")
Using this example, you could easily traverse any sequence of sequential elements, which would appear to solve your problem.
Take a close look at the structure of the page and then see how you would navigate to the element you need from a reference you can get to. There is probably an Xpath or css selector that can make the traversal across the document.
1 FYI, I'm using an old version of Selenium in Ruby, in case your version's syntax is different
My approach would be:
Get a list of all contemplable elements by the known id
Loop over them until you find a focused element
Use send_keys to write into that element
To get the focused element something like
get_element_index('dom=document.activeElement')
might work. See this question for more information.
Edit: If the list you get from 1. is accidently sorted properly the index of an element in this list might even represent the number of u'\u0009' you have to send to reach that specific element.
Use ActionChains utility to do that. Use following code:
from selenium.webdriver.common.action_chains import ActionChains
ActionChains(driver).send_keys("Hello").perform()