Using robot framework(with java) I need to pass the file path in a text field to upload the file. However, when i click on the text field it opens the File upload window pop up. In the DOM the field is marked as read only.Below is the screenshot of the DOM for the mentioned element.
enter image description here
Is there a way i can enter file path in to the read only text box?
Related
The website has standard image which i can use to identify the xpath.
but i want to click on the third image which contains specific text only.
the picture is beside the image, it that fine to have img and text in one command line?
Original working code:
driver.findElement(By.xpath("(//img[#class='s-image'])[2]")).click();
Try to insert the contains command but it does not work:
driver.findElement(By.xpath("(//img[#class='s-image'])[2] and contains(text(),'Apple MacBook Pro')")).click();
You have tried wrong option that is not text that is alt property to get into xpath.Try now.
driver.find_element_by_xpath("(//img[#class='s-image'][contains(#alt,'Apple MacBook Pro')])[2]").click()
OR
driver.find_element_by_xpath("(//img[#class='s-image'][starts-with(#alt,'Apple MacBook Pro')])[2]").click()
I was wondering if there's a way to load an HTML file on JavaFx's HTMLEditor but rather then loading it as a web page, show the actual raw source code on the HTMLEditor. Is this possible with JavaFX's HTMLEditor?
I tried the following:
File f = fc.showOpenDialog(null); //This allows a user to find a file in a dialog
String textRead = readFile(f); //store the files content in a string
htmlFileEditor.setHtmlText(textRead); //displays the source but not as raw HTML
This only loads the html file and displays it, Im wondering if there is a way to show the raw source code of the HTML file loaded with tags and all on the HTMLEditor.
I have a pdf form where user enters some info, like name and address.
Using iText, can I save new pdf file with user input? How can I get the text value of what user entered like this, stamper.getAcroFields().setField("name", nameTextBox.text);? Many sample codes use hard coded value but I want use what user entered in the textbox.
PdfReader reader = new PdfReader("C:/temp/Template.pdf");
FileOutputStream fileOutputStream = new FileOutputStream("C:/temp/TemplateTest.pdf");
PdfStamper stamper = new PdfStamper(reader, fileOutputStream);
//Can I do something like this?
stamper.getAcroFields().setField("name", nameTextBox.text);
stamper.getAcroFields().setField("address", addressTextBox.text);
stamper.getAcroFields().setField("city", cityTextBox.text);
stamper.getAcroFields().setField("zip", zipTextBox.text);
You have a PDF where the user enters some info.
Question 1: how can the user submit the form data?
[a.] The user can not safe the PDF locally, unless the document is Reader-enabled or if the user has a version of Adobe Acrobat (not Reader). Reader-enabling a document can only be done with Adobe software; see Editable PDF using itext (5.3.0) in java. Not able to save data in Adobe Reader X
[b.] The user can submit the fields to a server. This can be done in the form of a querystring, an FDF file, or an XFDF file. If the form is Reader-enabled or if the user has Acrobat, he can also submit the complete filled-in PDF to the server.
Question 2: how can you store the form data in a PDF?
If the user submits the complete PDF, then you do not need to store the form data in the PDF. It is already there. You can retrieve the info like this:
String name = reader.getAcroFields().getField("name");
If you get the information as a querystring, just examine the key/value pairs and use the code you already have in your question. If the information is stored in an FDF file, you need FdfReader. IF the information is stored in an XFDF file, you need XfdfReader.
Question 3: how do you use what the user entered in the textbox?
This question is unclear. What are you talking about?
If the text box is a text box in the PDF, see [a.] under question 1.
If the text box is a text box in a web page, see [b.] under question 1.
If the text box is a text box in some standalone application, see the answer to question 2.
All in all, your questions are of very poor quality. When you say 'many samples use hard coded value', it is clear that you didn't read the official documentation.
I want show the printable document directly with in the browser when I clicked on print button in my application. I already checked the 'Display PDF in browser' in adobe reader preferences and other PDF files are also being opened in my browser other than that my printable documents. Can you please suggest me
Thanks,
Vara Kumar PJD
Check that PDF sent as response when clicken on print button has correct MIME type (application/pdf). THis will allow browers to recognize it as PDF content and handle it as you want.
I want to display a regular XML or any other file in text format in JEditorPane..I don't want to display the content in html page... the content should be exactly the same as in file with line break..the XML file is located on local system
Do you need syntax highlighting?
or just show plain text?
If syntax try to use this
http://java-sl.com/xml_editor_kit.html
If not just use JTextArea or normal JEditorPane with default editor kit. And call setText() to set your content.