i need to URLEncode a date value that is taken from a datepicker control on my page. Currently I am trying to use the escape function to do this, but it is not working.
example: escape(datevalue);
any help would be appreciated.
got it, using EncodeURIComponent.
Related
/*[contains(text(),\'TextToFind\')]
When we find it through this xpath, Elements was not able to find it,
Once we remove slash its able to find.
It placed automatically, while passing through variables.
Any working solution with python-varible ?
You can use the python format() function to pass variable.
driver.find_element_by_xpath("//*[contains(text(),'{}')]".format(variableTextToFind))
I have tried everything that I can think of to get the right date format. Can anybody help with this RPA-problem in UiPath. I have used the 'get text' activity to get the folder date and after that tried to use the
Datetime.ParseExact(Str variable,"dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).
It gives me the error:
Assign: String was not recognized as a valid DateTime.
Your help is much appreciated.
edit: I have now sought help from a friend who figured it out. The error was in the string, which could not be seen, because there was an invisible character in the string that I extracted through 'get text' activity. The solution is in 2 steps:
assign another variable to the exact same date and use an if statement to find out if these two strings are equal and you will find out that they are not.
Now use a regex to capture only digits and slash/hyphen which will get rid of the invisible character.
Try to use "dd_MM_yyyy" instead of "dd/MM/yyyy".
The reason is because UiPath/VB.Net has a habit of using US date formatting even though you're using Culture Info...It's a real pain
Try this:
pDateString = "21/02/2020"
Assign a Date type variable = Date.ParseExact(pDateString,"dd/MM/yyyy",nothing)
Here we're telling the parser to use English format date...The Date type returned will be in US format but you can simply convert back to uk IF needed by using something like:
pDateString("dd/MM/yyyy")
I have used ends-with function as
(By.xpath("//input[ends-with(#id,'_PHONE$']"));
But it didnot work
The ends-with function is part of XPath 2.0 but browsers generally only support 1.0.
So, if you strictly want to fetch all elements that ends with a specific pattern, you can either fetch all elements that contain that pattern (using the contains() function) and then strictly check the suffix of the id (fetch the attribute value by .getAttribute("id")) using Java's .endsWith() method.
Or
You can use string-length function, substring function and equals to get this XPath:
"//input[substring(#id, string-length(#id) - string-length('_PHONE$1') +1) = '_PHONE$1']"
driver.findElement(By.xpath("//id[contains(text(),'PHONE$')]"));
You can use below XPath as well:-
//input[contains(#id,'PHONE$1')]
Hope it will help you :)
Your id is ending with _PHONE$1 and not _PHONE$. Notice that there is a 1 at the end.
(By.xpath("//input[ends-with(#id,'_PHONE$1']"));
If you still don't want to match that 1 use contains.
By.xpath("//input[contains(#id,'_PHONE$1']"));
Use contains Method
By.xpath("//input[contains(text(), '_PHONE$']");
Or use wait explicit method
I would like to get today's date in the following format: mmddyyyy.
Even if it's first of August I still want zeros in front, like so: 08012012.
I think I can use DatePart function for it, but I am not sure how.
Anyone has an idea?
Thanks.
You do not say which application, but in VBA, you can say:
Format(date(),"mmddyyyy")
Application.Text(Date(),"mmddyyyy")
Format(NOW,"mmddyyyy")
NOW gives time as well:
Format(NOW,"hh:mm:ss")
my SSRS DataSet returns a field with HTML, e.g.
<b>blah blah </b><i> blah </i>.
how do i strip all the HTML tags? has to be done with inline VB.NET
Changing the data in the table is not an option.
Solution found ... = System.Text.RegularExpressions.Regex.Replace(StringWithHTMLtoStrip, "<[^>]+>","")
Thanx to Daniel, but I needed it to be done inline ... here's the solution:
= System.Text.RegularExpressions.Regex.Replace(StringWithHTMLtoStrip, "<[^>]+>","")
Here are the links:
http://weblogs.asp.net/rosherove/archive/2003/05/13/6963.aspx
http://msdn.microsoft.com/en-us/library/ms157328.aspx
Here's a good example using Regular Expressions: https://web.archive.org/web/20210619174622/https://www.4guysfromrolla.com/webtech/042501-1.shtml
If you know the HTML is well-formed enough, you could, if you make sure it has a root node, convert the data in that field into a System.Xml.XmlDocument and then get the InnerText value from it.
Again, you will have to make sure the text has a root node, which you can add yourself if needs be, since it will not matter, and make sure the HTML is well formed.
If you don't want to use regular expressions (for example if you need better performance) you could try a small method I wrote a while ago, posted at CodeProject.
I would go to Report Properties and then code and add the following
Dim mRemoveTagRegex AS NEW System.Text.RegularExpressions.Regex("<(.|\n)+?>", System.Text.RegularExpressions.RegexOptions.Compiled)
Function RemoveHtml(ByVal text As string) AS string
If text IsNot Nothing Then
Return mRemoveTagRegex.Replace(text, "")
End If
End Function
Then you can use Code.RemoveHtml(Fields!Content.Value) to remove the html tags.
In my opinion this is preferable then having multiple copies of the regex.