How to display clickable hyperlink in Papplet Java application? - java

I know how to display simple text with the processing.core.PApplet.text method.
But this one can't display clickable hypertext link. How could I make that in Papplet ?
I precise that link should open the web browser.
Thanks.

It's not documented on the main Reference page at http://processing.org/reference/, but you can use a function called 'link()' ... it takes up to two parameters - the url to go to, and if the second argument is supplied, sets whether to open a new page or not...
Eg.
link("http://www.processing.org", "_new");

Related

How to click on file-attachment icon using selenium (with java)?

I am creating automation that automatically sends messages through LinkedIn. The code is working fine, but as per our current requirement, I want to click on the attachment button so as to pass the attachment also with the text message. There are a few points that I have already tried:
Unable to fetch the element ID as its dynamic most of the time.
Don't want to use offsets (x,y) because once anyone changes the size of the window offsets changes.
Unable to use XPath.
Then I checked for another tool "UIVision" which makes a solution to capture that particular area (save it in a .png file) from the page where we want to click and during runtime it clicks there. So I tried searching image comparison API for java, tried with ASHOT and Sikulix too but none worked for me.
Anyone can help me with this?
When you say your unable to use xpath will you please elaborate?
The button has an id - it's attachment-trigger-ember1079.
If you're concerned about the latter part being dynamic, the attachment button also has a good title.
You can try using xpath string:
//button[contains(#title,'Attach a file')]
For me, on my linked in, this returns a unique hit on the expected attachment object:
If these don't work, there's also the option of using javascript to action the upload.
For more information on handling the upload dialog (after your identify the object) have a look here

How to use Selenium and Java to interact with dynamic web element?

I want to use Selenium to interact with an element on a website. This element contains further content depending on the user's behavior, but obviously has exactly one HTML-element the whole time.
The element looks like this when the mouse is not on top of it:
When the mouse is on top of it, it looks like this:
When the user clicks on the down arrow, other content is visualized:
As you can see it contains even more logic, I didn't add screenshots for it though.
The corresponding HTML code is that, nothing more:
I do not know how this content is created. Does anybody know how I can use Selenium and java to interact with that web element? Selenium is obviously restricted to HTML content - what can I do without trying any dirty hacks like positioning the mouse at a certain position on the element myself to trigger the different visualization?
Update
I want to do automated end-to-end testing. That means I need to programmatically use the buttons of the web element as a user would:
Delete the date by clicking the x button
Alter the date by clicking up and down buttons
Alter the date by using the calender component
Changing the text in the web element (I guess I might already be able to do that with my current knowledge of Selenium)
I talked to the developer of that application and he told me he actually just adds one HTML input element of type date to the application. The rest (i.e. the renderer/editor of that input field as I presented in the question above) is totaly browser-specific. It looks like that in Chrome and entirely different in Firefox.
The above described web element seems to be the regular HTML 5 DateTime selection in Chrome. With that knowledge you can find the web element yourself and a tutorial for Selenium here: https://www.guru99.com/handling-date-time-picker-using-selenium.html and another discussion similar to my question here: How to set HTML5 type="date" input fields (e.g. in Chrome) using Selenium/Protractor?
The guru-page obviously describes how to control the full web element and it seems to work. I will check this out and accept this as the answer for now. Thanks everyone for your time!

Jumping from screen A((Web Page) to Screen B(Web Page) bypassing intermediate screens(Web Pages) using selenium webdriver

This question is not about window handling or juggling of multiple browser windows, its about navigating through web pages of a web application within same window.
I have a situation where
1.I navigate as screen A->Screen x->Screen Y-> Screen B
2.I need to capture certain parameters on screen B from First login
3.I need to verify those parameters on screen B from second login
Here what i wish to do is to avoid the non important task of navigating through intermediate screens & jump directly to the concerned screen. Or directly capture the concerned parameter without bothering about UI.
Note- The URL on this application window is non editable manually.
Example-
Login->Jump to Screen B(First Login)
Login->Jump to Screen B(Second Login)
Firsts of all, is it possible at all??
Please help me with the suggestions of how to achieve this
Additional Detail-
URL to view a project named Selenium Test 275 (A specific web page in the application) is ->
http://172.24.186.71/esssfa/sfanew/UnitList.aspx?OID=12762&PID=12731&PRID=1&SecID=3
Edit:
I think I understand what your asking now. If you want to easily jump back a few pages, to that spefic screen B, I would use JavaScript.
(-1) will get the last page that was on your browsers stack. (-2) two pages, and (2) will then make the browser get two pages forward on the browser.
If you want to go back to Screen B try something like this after logging in.
driver.execute_script("window.history.go(-2)")
Then a variable can be used to store the data from the last login that you want to compare.
Possibly that the second window opens based on response from the server?
For e.g - the server could be returning a URI along with a session/security attribute(JSESSIONID, Authorization, etc) which is then appended with base URI to open up the new window. The session/security attribute explains the invalid session page message when you try to driver.get(URL) of the second page.
At the risk of being repetitive (rephrasing Vivek's question) - are you able to open the second screen in this way :
Login to the application (first screen) -> Open a fresh browser window -> Paste the (read-only) URL of the second screen and hit Enter -> Check second screen opens.
If yes, then it seems to be a case where it is not just simple GET request but possibly a request with some sort of Authorization code in the request headers.
Additional details might help answer your question : is it possible ?!

Java : Take screenshot of visible area in the browser

Is there a way to take the screenshot of the display in a browser in Java minus the browser window. The flow is :
Load the webpage in a browser. Then make an AJAX call to a Java service which captures the screenshot using the code from : How to take a screenshot in Java? .
The problem here is that I only want to capture the visible area in the browser excluding the browser window, the windows task bar and the other unwanted stuff.
Thanks
You can just measure how big is the displayable area and capture that section only.
As for the AJAX call to a Java service part is not posible.
As #OscarRyz already mentioned AJAX call is irrelevant here.
You have to create java applet that calls new Robot().checkScreenCaptureAllowed(). This will capture whole screen.
The problem is how to understand where the visible area is. You can probably do it. You have to create at least one visible element in your applet. This element could be even very small (e.g. one pixel), so user will not see it. Then you can invoke getLocationOnScreen() that gives you the absolute coordinate on screen. If your java applet is in the top-left corner this is the point where your visible area starts.
JavaScript allows you to know the height and width of current window: window.innerWidht and window.innerHeight. So, you now you can take your screen capture and cut the area that you need.
But please take into consideration that new Robot().checkScreenCaptureAllowed() checks READ_DISPLAY_PIXELS_PERMISSION and I do not believe you have such permissions for unsigned applet, so you will have to sign your applet.
To avoid this problem take a look on this: http://html2canvas.hertzen.com/ - script that "captures" screen and uses JavaScript only.

Hyperlink in J2ME

How I create hyperlink in J2ME?
After click the string item J2ME has to open website in system web browser.
See the same discussion on nokia forum. It will helps you.
Better create your own Button component by extending Item class and overriding paint to draw text with specified font and underlined and also you can add Action listener to it so that you can perform action
usable in forms too.
you need to use Platformrequest method to launch link in webBrowser .
Just check string is valid web address or not.

Categories

Resources