Nothing happens when using I.attachFile to upload a document , can you suggest what I should do - photo

Is a drag-and-drop field required for the I.attachFile('element', 'filePath') to work? Because currently nothing happens when I try using the attachFile method. No error message or any issues displayed even when using --verbose.
This is the element where I try to attach my file //input[#type='file']. I also verified that I have the correct fileName and filePath since I tried using a wrong file name and it returned an error.
I am currently using:
codeceptjs: ^3.3.6,
playwright: ^1.19.0
I tried changing the file I'm about to upload to see if my file is the problem, but when I do upload the file manually in the page it works as expected; but when trying to do it in my code, nothing happens.
Expected: The uploaded file's name should be displayed
Actual: Nothing happens; no file name displayed; no error message returned in the logs
i expected the file to be uploaded.

Related

how to verify text present in placeholder in selenium IDE

I want to verify the text present in placeholder. I have located the element and i am using Assert text command. I've entered the same string in value. On executing it is showing actual value did not match
Use assertAttribute or verifyAttribute command.
Example:
verifyAttribute | css=#search#placeholder | Sample String
Notes:
In the Target column of Selenium IDE, you need to provide the proper path of the element followed by an # sign
and then the name of the attribute. (placeholder in your case)
Using
verifyAttibute will still continue running the test case once an
error is detected while using assertAttribute doesn't.
You need to understand that assertText function can only check static text on your webpage.
You must be getting an error message.
This is perfectly normal.
What can help in this situation is using the assertAttribute or verifyAttribute functions.
Both these functions perform the same task; the former stops the test after receiving an error message in the text box while verifyValue just records the error in the log and runs the next commands.
While giving the target, either specify the XPath or refer by using the name=name#placeholder format.
You can find the name value by inspecting the box with a firefox addon called Firepath which runs with another firefox tool called Firebug. Install them if you don't already have.
Hope this helps!
Xpath contains() is the best way.
driver.find_element_by_xpath('//input[contains(#placeholder,"email")]')
Format : '//tag[contains(#attribute,"value")]'

PHPmailer: attaching a session variable to an email

Due to the fact that I have to create a PDF on my server using the uniqid() function, I must subsequently refer to it as a PHP variable in the rest of my code.
The variable that I create for it is a session variable. I later refer to this session variable in a separate file, which contains my PHPmailer code. I use the following line to attach the session variable to the mail:
$mail->AddStringAttachment($_SESSION[$attachment], "attachment.pdf");
The mail is sent correctly with a PDF attached, called attachment.pdf. However, this attached file, attachment.pdf, is empty. This is despite the fact that the PDF on the server, which the session variable refers to, contains the complete set of data. If I attach the name of the PDF, instead of the session variable, it works correctly.
I don't know why the use of a session variable when attaching the PDF is resulting in an empty file being sent. If anybody may be able to explain why this is happening, or suggest an alternative solution, I would greatly appreciate it!
I'm guessing that $_SESSION[$attachment] contains the name of your generated PDF file, so what you are doing here is attaching the name of the file as an attachment, rather than the file itself. You should probably be using this instead:
$mail->AddAttachment($_SESSION[$attachment], "attachment.pdf");

Include file as input stream in scala

I'm having problems with using a file in my code. I'm working with javaPNS and trying to get it to work. What I think is wrong now is how I get my file for the keystore parameter in the Push.alert method in javaPNS.
What I'm really wondering is how do I "get a resource" properly so it has the correct format?
Here's the exception that is thrown:
javapns.communication.exceptions.InvalidKeystoreReferenceException:
Invalid keystore parameter (null). Must be InputStream, File, String (as a file path),
or byte[].
at........
And here's how I currently include the file:
val keystoreFile = getClass.getResourceAsStream("/app/conf/cert.p12")
If we look at the exception I get, do you think this above is the problem? How should I include the file properly in Scala?
regards,
The problem you are seeing has to do with the fact that the InputStream you are loading is coming back as null. This happens when the file you are trying to load can not be found on the class path. Try changing your code to:
getClass.getClassLoader.getResourceAsStream("app/conf/cert.p12")
You will notice I removed the leading slash on the file path as I believe this is your issue. Then just make sure that whatever the parent directory to "app" is is on your class path.

Moodle local plugins and save_file

I've created a working form within a local plugin and it is inserting data fine into my custom table.
What I want tyo add now is a filepicker element that upon saving the form puts the file into a specified folder.
The filep[icker itself works fine but when I save the form no file appears, the code I'm using looks like this:
$mform->save_file('lowresCh', '/my_form/', false);
I've tried various things in the 'my_form' bit, but to no avail. The rest of the form still puts its data into the custom table and I can see my file in the mdl_files table (marked as draft).
With full debugging on I can get a warning of:
Warning: copy(/my_form/): failed to open stream: Is a directory in /...../lib/filestorage/stored_file.php on line 390
I don't know if I'm approaching it incorrectly or not, any help or pointers in the right direction would be most appreciated. 
Oh and I have read the Using the File API in Moodle forms page, useful in getting me to the point I'm at, but no further.
I solved it by using the filename as the second argument in save_file() and if I prepend a directory then all of the files will be saved within my plugin in a sub directory which is perfect.
So it looks like this now:
$mform->save_file('lowresCh', 'files/'.$mform->get_new_filename('lowresCh'), false);

Joomla template parameters and params.ini - file becomes unwritable after save

I am using wamp on Win XP SP3 and creating a Joomla template with changeable parameters.
initially the message is
The parameter file \templates\ssc_2010\params.ini is
writable!
once I make changes everything works as expected, except now i get the message:
The parameter file \templates\ssc_2010\params.ini is
unwritable!
One solution is to brows to the directory, right click the file, select properties, and uncheck read-only. Again the file is writable but once I modify the parameters again it becomes read only again. I'm quite lazy and would like to prevent this from happening again, I've notice this happening in past projects, but now I have to work a lot with parameters so it becomes quite boring doing manual labor like that :P
There is a bug in Joomla 1.5 that causes the message to be displayed.
A security feature was added that makes the template files unwritable until just before save, where they are made writable, saved, then made unwritable again.
Try to make a change, then go back and check the preview. You will see that the change was actually made.
If you want to fix the annoying unwritable message, add the following code to
administrator/components/controller.php around line 179, just after setting the FTP credentials:
$file = $client->path.DS.'templates'.DS.$template.DS.'params.ini';
// Try to make the params file writeable
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file writable'));
}
This will make the file writable during the edit load process, and before the file's status is posted in the template.
Then for security, in case the edit screen is closed without saving, search for the following lines:
require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
TemplatesView::editTemplate($row, $lists, $params, $option, $client, $ftp, $template);
and paste the following code just AFTER these lines but before the closing brace:
// Try to make the params file unwriteable
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file unwritable'));
}
That will make the file unwritable again.
This is the same code that is used in the saveTemplate() function. We are just doing it again before we display the status of the file on the edit screen. If the process fails because of your web server's configuration, you will get warning messages, BEFORE you've made a bunch of changes to your template. :)
P.S. Remember to save a copy of this file separately, so that you can redo the changes when you upgrade Joomla! (if they haven't fixed this themselves yet.)
This sounds like a user rights problem within Windows - have a look a the security permissions for the directory in which the file you are editing is located, and check that the user "IUSR_xxx" (where xxx is the name of your computer) has full control.
If this doesn't work, then can you tell us what version of Windows you are running as this may help...
Matt