Paste into text area - java

I tried to make my day easier making a program that will register my self into card game tournaments via selenium webdriver. I am beginner so I was thrilled even though it was just basics aka click here, confirm this, write that but at the end I ran into a problem that I am having trouble solving.
At the end you need to submit decks via deck code. The sendKeys function? (not sure if thats the correct wording) does not work since it actually needs to be pasted into the text area. Whenever you try to "just" write into the box it says its invalid deck code.
driver.findElement(By.xpath("//*[#id=\"react-root\"]/div/div/div[2]/div/div[2]/div/div[4]/div[1]/div/textarea")).click();
driver.findElement(By.xpath("//*[#id=\\\"react-root\\\"]/div/div/div[2]/div/div[2]/div/div[4]/div[1]/div/textarea")).sendKeys(Keys.chord(Keys.CONTROL + "v"));
I went with this, first line just clicking in to the text area and then trying to paste it in (while I copied the deck code manually, not sure how I will solve this since I need to paste 3 different ones, but that is issue for the future) but the code just wont paste and I have no idea where is the catch. I tried the paste function in different text area with the same settings meaning I have something copied in my clipboard and it worked just fine.
Example of the deck code is
" AAECAZICCiT3A94FrtICv/IC9fwC2KAD+KED9KID/KMDCkBWX/4BxAapogPIogPcogPvogPZqQMA "
I hope I provided everything I should have otherwise let me know and I will gladly post more :) Thanks in advance and I hope someone can help me

This might not work because I don't see you explicitly copying the deck code, as you mentioned you did it manually. I also modified your example to not use Keys.chord, as you might not need them here.
To copy the element:
deckCodeWebElement = driver.findElement(locatorToFindDeckCode);
deckCodeWebElement.send_keys(Keys.CONTROL+'a')
time.sleep(1)
deckCodeWebElement.send_keys(Keys.CONTROL+'c')
Then, to paste:
deckCodeWebElementToPaste = driver.findElement(locatorToFindDeckCodeToPaste);
deckCodeWebElementToPaste.send_keys(Keys.CONTROL+'v')
On another note, I recommend shortening your XPaths to relative notation, as the absolute notation you are using is very brittle and breaks very easy. You want to find elements irrespective of their location in the DOM tree.
You can change this:
//*[#id=\\\"react-root\\\"]/div/div/div[2]/div/div[2]/div/div[4]/div[1]/div/textarea
to just this:
//textarea
You may need to query on something like ID, class, or name if there are multiple textarea elements, but there is no need to start at the root node and use div[2] and div[4] unless absolutely necessary.

Related

Printout problems on Bluej

I wanted to print a few programs for a school project on bluej. When I click the print button and set the paper size to A4 and give 'OK' the print comes in a weird small box. I tried increasing the font size. No changes happened. I also changed the page type to the different ones available, but no luck. Please tell me how to solve this problem.
There are two possible ways to solve your problem. The first is to copy-paste your code into another program, for example Word. The second way is to printscreen the code you want to print and then spread this picture across the A4. Maybe you should cut the edges off first.

Is there an easy way to show borders around Views and ViewGroups in the design tab of Android Studio for debugging and styling purposes?

I would like to see visually how much space each box takes with as little effort/changes to the code as possible.
I would like to know if it's possible to just put a line around the outer margins of the View or ViewGroup object.
Since it's just for debugging and styling I would like to also quickly turn it off, so I do rather make the changes to my code in one place so it's easy and quick to undo. Is this a default option I am missing? Somehow I expect this feature to exist already.
Here someone asks a different but slightly related question with not a nice answer for my case.
Here someone gives an answer on how to outline one View.
Border for an Image view in Android?
Code-wise you could follow the answer to the first link you posted and create a drawable with the name "developer_borders" or something similar and apply it to every view you wish to have its borders visible.
To easily remove it afterwards, you can right-click the directory of your project and click Replace in Path.... For Text to find you want to search for android:background="#drawable/developer_borders and for Replace with don't use anything. This will find every occurrence of what you are searching and replace it with an empty string.
There might be an easier option. Some devices have quite powerful Developer Options. "Show layout bounds" is what you want but take a look at the rest while you are at it, some are pretty awesome.

Display a scrolling message that can be updates by another webpage

I'm looking for a solution to this and I have searched the web for an answer with nothing. I need a scrolling message on my webpage that can be updated by the same website but on a different page. (e.g www.webpage.com <-- has the scrolling message on it, www.webpage.com/settings <-- has a form in which you can change/update the scrolling message)
I'm pretty sure this is achievable with Java, but my knowledge on Java is slim and all my efforts have come to a fail. I have managed to get a scrolling message on my webpage and I'm sure if I could read a text file (with the message in) then assign that to a 'var', I could make that scroll but I don't know how to do that.
If you know a completely different method of doing this I am happy to change mine.
Thanks in advance,
Tom.
I would recommend javascript instead of java, since java is not really conventional anymore and looks ugly too (and requires a special plugin).
It depends on how fast you want to update the scrolling text how you want to do this. I would say save the text to a .txt or database from settings, and then have your page get it.
You can then use php to read the value from the .txt file or database to display it on your website.
If you want it to be extremely up to date you can let javasript call a little .php file that reads the file and gives you the content.
To make your text scroll you don't really need anything other than html, like so:
<marquee behavior="scroll" direction="left">Your scrolling text goes here</marquee>
You can read more about that here: http://www.quackit.com/html/codes/scrolling_text.cfm

Eclipse IDE Scope Highlighting?

When I first learned Java, I was using an IDE called "BlueJ." It had this feature called "Scope Highlighting" which made it very easy to read blocks of code. Now I've moved on from BlueJ and began using Eclipse. I'm currently in the process of customizing Eclipse to my liking and would like this Scope Highlighting feature inside Eclipse.
I've searched everywhere for an answer on how to do it but I cannot find any information pointing to a solution for doing it in Eclipse.
Here's a picture to demonstrate what Scope Highlighting looks like:
I think the best option for you is EditBox, a scope highlighting plugin for Eclipse:
http://editbox.sourceforge.net/
I'm afriad that closest you can get is Shift + Alt + arrow_up
It is selecting wider block of code. pressing this few times will give you very similar result to what you are searching for. I use it often.. it is useful, also for refactoring.
EDIT: As #j2emanue said: you can just double click the delimiter (like a bracket) and it will highlight the entire scope.
you can use Shift + Alt + arrow_up but many people dont realize you can just double click the delimiter (like a bracket) and it will highlight the entire scope. Try double clicking your if statements bracket for example and watch eclipse highlight the entire scope. It works with any delimiter. so you can use parenthesis as well.
as a side note: if your using intelliji checkout this plugin works great: https://github.com/izhangzhihao/intellij-rainbow-brackets#screenshots
This isn't exactly what you're after but you can put your cursor in a method and then click the Show Source Of Selected Element only button on the toolbar. Your editor gets reduced to just that method. Click again and your back to your entire file.
I doubt eclipse does have the same function as blue j.The best advise I can give you, is to change your theme to your liking which would enable you to easily select and highlight the block of code...and to customise your theme , go to http://eclipsecolorthemes.org/. ....
If you still have a problem, go to http://codejava.co.uk/contact.html and send your email.you can create a dummy one if want, then I will send you XML files I use for my eclipse themes.
can Bracketeer do this ? its an eclipse plug in ..
http://marketplace.eclipse.org/content/bracketeer-java-jdt#.UK6sY4fAdLc
Maybe you will also like the VSCode extension "Blockman". It highlights nested code blocks based on curly/square/round brackets, html/xml tags and Python/Yaml indentation. (I am the author of Blockman).
.
https://i.ibb.co/31F0rm9/vscode-blockman-intro-leodevbro-extension3.png
.
.

Dynamically changing the shown form on tree selection

I'm currently learning the adf framework, and while doing this I found myself in a situation I am not able to solve.
I have a tree component that works fine. I also have different forms, corresponding to different levels of the tree. Rather than having all of the forms visible at one time, I would like to only show the one that corresponds to the selected item in the tree.
To solve this, I created af:switcher, created facets and moved the forms there. Here is where I am lost, how do I tell the switcher to change the form? I tried to link them together using the facetName on the switcher, but no success. I suspect I did not link the right thing there, but I could not find anything helpful from the tree either! I assume it has something to do with the selectionListener and a bean, but I could not figure out a way to do this. Any clues?
See Sample #50 of http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html#CodeCornerSamples
Frank

Categories