How can I manipulate DOM with Java? -


is there way can dom element , manipulate can put username , password in order login automatically, when starting application? now, i've used robot in order let computer pass in login information , login automatically, need better method. appreciated!

import java.awt.awtexception; import java.awt.desktop; import java.awt.robot; import java.awt.toolkit; import java.awt.datatransfer.clipboard; import java.awt.datatransfer.stringselection; import java.awt.event.keyevent; import java.net.url;  public class main { private static string os                = null; private static integer ctrl             = null;  private static string username          = "u1240430"; private static string password          = "123123";  public static void main(string[] args) {      os = system.getproperty("os.name");     if( os.equalsignorecase("mac os x") ){         ctrl = keyevent.vk_meta;     }else{         ctrl = keyevent.vk_control;     }       try {         desktop.getdesktop().browse(new url("https://awebsite.something/login.php").touri());         startwithlogin();     } catch (exception e){         system.out.println(e.getmessage());     } }  private static void startwithlogin() {     try {         robot r = new robot();          stringselection selection = new stringselection(username);         clipboard clipboard = toolkit.getdefaulttoolkit().getsystemclipboard();         clipboard.setcontents(selection, null);          r.delay(1500);          r.keypress(ctrl);         r.keypress(keyevent.vk_v);          r.keyrelease(keyevent.vk_v);         r.keyrelease(ctrl);          r.delay(100);          r.keypress(keyevent.vk_tab);         r.keyrelease(keyevent.vk_tab);          r.delay(100);          selection = new stringselection(password);         clipboard.setcontents(selection, null);          r.delay(100);          r.keypress(ctrl);         r.keypress(keyevent.vk_v);          r.keyrelease(keyevent.vk_v);         r.keyrelease(ctrl);          r.delay(100);          r.keypress(keyevent.vk_enter);         r.keyrelease(keyevent.vk_enter);      } catch (awtexception ex) {         system.out.println(ex.getmessage());     }   } } 


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -