Edit: Another thing you will notice, 307 is the interface ID for the chatbox, you're checking if its not null which is always, you never check however if the interface your trying to interact with is visible.
if(client.getInterface(307).getChild(6).isVisible()){
//interact with it
}
Do the above and you will find it works.