I have looked around and could not find any threads with a solution to this yet. I am trying to make a program for a specific website, it interacts with the website just like user would do and it does so how the user wants it to interact. I'm using Selenium right now and just grabing WebDriver and making it do a list of tasks, but I want the WebDriver to interact how the user would want it to.
So is there any way to lay a "skin" on the WebDriver? So like a button where if selected it does a certain task? And is there a way to remove the URL bar and make a gradient border around the Browser to make it look like a program? Or should I be using something else in order to accomplish this?
Here is an "image" of what it would look like:
http://i39.tinypic.com/okn0rd.jpg
Where only the black is visible and the brown isn't there, or not visible and there are "buttons" over?
So would this be possible with any WebDriver through Selenium or should I be using other ways to interact with the webpage in order to accomplish this? Don't need to do my homework for me, but I would appreciate refrences to where I could do this. I was thinking of using HTMLUnit and just making a headless browser that does all this in the background and prints a picture and I can display that in a Java Program with all the buttons over it?
Related
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!
We have diagram application which is built using Canvas and GoJS. There are many controls in toolbox and I would like to drag particular element to blank area.
I have tried by actions method but that is not working.
I tried code :
actions.moveToElement(paletteCanvas, palette_node_x, palette_node_y);
actions.clickAndHold();
//Dragging selected node a little bit to make it work.
actions.moveToElement(paletteCanvas, palette_node_x, palette_node_y+50 );
//Now perform the actual move
actions.moveToElement(flowCanvas, diagramOffsetX , diagramOffsetY);
actions.release();
actions.perform();
Also it is hard to find offsets for element. Is there any there way by which I can automate following using selenium :
Drag and Drop any control fro toolbox
Select any particular control from tool box
Any possibility to work by JSexecutor?
These links might be helpful to you:
http://forum.nwoods.com/t/how-to-implement-selenium-test-cases-for-canvas/5195
http://forum.nwoods.com/t/locating-elements-on-canvas-by-selenium-webdriver/5509
http://forum.nwoods.com/t/simulate-selectionadorrnmenttemplate-click-selenium/6134
Selenium rookie here with a question regarding drag and drop.
I have two boxes and from one of the boxes i can drag a line and connect it to the other box.
I have tried various ways but none of them seem to work.
Actions action = new Action(driver);
action.dragAndDrop(box1 , box2).perform(); // Did not work
action.clickAndHold(box1).moveToElement(box2).release().perform(); //did not work either
action.clickAndHold(box).moveByOffset(coordonates of box2).release().perform(); // also did not work
This is were my knowledge of selenium stops , is there any other way i can do this?
I know the xpath is good because when i perform element.click(); it access it so its not that.
Selenium's actions for drag and drop do not play nice with HTML5, when you trying to move element to some frame and in several other situations. Possibly you can solve your problem using this jQuery solution:
[C#][Selenium] How to drag-hover-drop an element
I am working on a research project.The scenario is this.
I am taking the screenshot of my desktop and then I process it using an API to get the position of a certain text on my Desktop.e.g , say I have the browser open on my desktop and I am on stackoverflow.Now I want to search the position of the logo stackoverflow on the screenshot taken.Then I want to simulate a click on it.I am using Java platform.
Now I have 2 questions:
1)Is there any free API(OCR) which I can use to process the screenshot to fetch text position (or can be done by some trick) and gives good results.
Or Any way you can suggest that I can use (instead of taking screenshot and processing it) to get the position of any text on the screen.
2)How can I simulate the click on the screen using the code by a background program running(I mean I have done it in Swing and other language UIs but this time its different as Now I want to click on the screen.
If I understood you right you want to move your mouse and click on the screen. That not that hard you could use the robot class from Java!
For example:
Robot rob = new Robot();
rob.keyPress( KeyEvent.VK_ENTER );
or what ever, there are so much bottons and movements you could with it. A list of all methods you find here.
And your other question I can't answer. I think there is no API that is able to search a text and give you the position. But what I know is that the robot class is able to capture the screen and put it into a BufferedImage. With it you could compare two pictures.
Maybe you could get use of this but I don't know if it is what you search.
Firstly I am no longer a student and doing this for other purposes, so don't hold back on the help ;)
I want to incorporate a simple program into my webpage. I want 4 buttons labelled right arm, left arm, activate voice and walk forward. There will be a box above these buttons showing an image of a robot and as the buttons are pressed by the user I want a different image to be loaded in the box.
So if the right arm button is pressed the image with the robot raising its right arm will need to be displayed.
So basically all I want the buttons to do is to load the image that belongs to each one. I am assuming java is the best choice? I have the open source Java package, would I need any other software when it comes to embedding it into a webpage? My webpage is done on dreamweaver and I am pretty good with html. Would appreciate it if someone could point me to the right direction.....Thanks
Don't use Java for this. Use JavaScript. Something like this:
HTML:
<img src="one.jpg" id="firstImage" />
<img src="two.jpg" id="secondImage" />
<button id="doSomething">Do Something</button>
<button id="doSomethingElse">Do Something Else</button>
CSS:
img {
display: none;
}
JavaScript:
var hideImages = function() {
$('#firstImage').hide();
$('#secondImage').hide();
};
$('#doSomething').click(function() {
hideImages();
$('#firstImage').show();
});
$('#doSomething').click(function() {
hideImages();
$('#secondImage').show();
});
What this essentially does is initially display no images, just buttons. Then as each button is clicked, the corresponding image is displayed. (And all other images are first hidden, since previous button clicks would have displayed previous images.)
This is an overly simple proof of concept, of course. At the very least you'll want to use better variable names :) This just demonstrates the idea of how you'd show/hide images in JavaScript in response to button clicks. (This also assumes the use of jQuery, which is a safe assumption these days. The easiest way to use that is to refer to a CDN link in your page, using a standard HTML script tag.) You can see this code in action here (though the images are broken, of course.)
If there are a lot of buttons and a lot of images, you may be able to re-factor the code to be less repetitive as well. Maybe store the images in an array and have a single button click handler which can associate the sending button with the correct array element, etc. That's up to you.
There are many technologies that could help you: javascript is one of them and it would be much simpler than using Java for such simple thing. You can use Java applet if you really want to use Java for that project.