attach_file option in Helium Scripts - helium

I am pretty new in Helium Scripts. I am trying to use attach_file option as mentioned in API documentation of Helium. But it does not attach the file.
Syntax I am using: attach_file("C:\xxx/xxx.csv", to="File name:")
Please guide me.
Thanks
SP

Well the way you are trying to attach a file is not right. The right approach should be following
attachFile("c:/test.txt", to("Please select a file:"));
So in the above syntax attach_file this should be attachFile
("C:\xxx/xxx.csv", follow C:/xxx/xxx.csv format
to="File name:" Here instead of file name there should be String, WebElement, HTMLElement or Point )
So the final findings is syntax for attaching file is attachFile("file path from where you want to attach", to("WebElement, HTMLElement or Point" where you want to submit))

in case anybody needs it now for Python. This is an excerpt from helium docstring:
attach_file("c:/test.txt", to="Please select a file:")

Related

Is using Javascript in odoo.fields.HTML possible?

I want to integrate Adobe Captivate Content (Export: index.html, along with src-folder) into ODOO Community Edition v13 e-Learning Module (website_slides).
The slide.slide model already offers slide_type 'webpage' alongside the field 'html_content'.
The field 'html_content' is of type odoo.fields.HTML. To get the requirement stated above to work, I need to embed Javascript in the given html_content. It seems like the JS-scripts are not working. I also tried with a simple Hello World script.
Can someone help?
Best regards,
Lars
I found the solution already.
Looking at odoo/fields.py -> class Html, you can see that by default the given value is being sanitized using odoo/tools/mail.py -> html_sanitize(), which removes the HTML-Elements in 'tags_to_kill'. 'tags_to_kill' also contains "script".
After overriding html_content in slide.slide with the following, the Javascript-code is being executed:
html_content = fields.Html(
sanitize=False,
sanitize_tags=False,
sanitize_attributes=False)

JDownloader2: Formatting links for Linkgrabber

Is there any way of formatting a list of links in a text file, so JDownloader's Linkgrabber knows the package name I want?
For example:
{{packagename1}}http://link-a
{{packagename1}}http://link-b
{{packagename2}}http://link-c
{{packagename3}}http://link-d
{{packagename4}}http://link-e
{{packagename4}}http://link-f
Will put link-a and link-b in "packagename1", link-c in "packagename2", link-d in "packagename3", and link-e and link-f in "packagename4".
Someone in Reddit pointed me to the solution.
If we look in Settings / Packagizer, there's a rule editor.
A custom rule can be made that takes links in the format:
http://link-a#packagename=packagename1
Which puts the downloads found in the link in a package named "packagename1".
(Original image by the user that provided the answer, grooters)

How to find some text on webpage and show it in textbox (or just write it out) using Visual Basic?

Let's say I have a www.exmple.com website, with some text on it;
Example 1
Example 5713
Example 151
Example ...
and so on...
I would like to create a program where the user could input what is he looking for ON www.example.com... Like he is type "Example 151", it will show in a new textbox or something that can actually store text.
Is this possible?
I hope someone can help,
Thank you!
Is this possible?
Yes, certainly. You need to use an HTML parser - a library that can read the HTML and that you can then query it for.
Two popular options are the HTML Agilty Pack (uses XPath for querying) and CsQuery (uses jQuery like query syntax).

is it possible to reference .linq file in LinqPad

is it possible to call/reference functions in another query file beside MyExtensions in LinqPad?
You can call one script from another:
Another way to combine scripts is to dynamically execute one script from another. The Util.Run method does exactly that, and is useful in both interactive and command-line scenarios:
string htmlResult = Util.Run ("test.linq", QueryResultFormat.Html).AsString();
Note: If you feed Util.Run a relative path, it will resolve it relative to the 'My Queries' directory rather than the current directory. You can switch its behavior by specifying .\test.linq instead of test.linq in this example.
From:
LINQPad Command-Line and Scripting
No, this isn't possible right now.

sahi script for choosing and uploading a file

I'm using Sahi for Test Automation of web application. I have to write a script for sahi for uploading a file. But unfortunately I don't know the way. Can anybody please help me?
File upload can be a complex thing depending upon any validations you do on the upload. For a starter, you can try out the following:
Synatx:
_setFile(element, filePath [, actionURL])
eg:
_setFile(_file("id"), "C:\abc\efg.jpg", "formSubmit.jsp");
If there are javascript validations on the file field, you can try this hack. Before submitting the file, change the field’s type to “text”, and then set its value. Eg.
// set the file
_setFile(_file("file"), "scripts/demo/uploadme.txt");
// Change the "type" attribute of file field
if (_isIE()){
_call(_file("file").outerHTML = _file("file").outerHTML.replace(/type=['"]?file['"]?/, "type=text"));
}else{
_call(_file("file").type = "text");
}
// Set the value into the textbox
_setValue(_textbox("file"), "scripts/demo/uploadme.txt");
This works for most of the cases. If you still get any error, you can post it here.
Thanks,
Vivek
You can use the following
_setFile(_file("id"), "C:\\abc\\efg.jpg");
Not sure if you need anything more complex?
Note that as of Sahi 4.3, there is a _setFile2 function that automatically handles js validations and does this input type conversion.
I've solved using the function setFile2, with internally changes the type of field to text