I am trying to send a new message to myself with CasperJS and I need that message contains a link <a href="www.example.com"></a>
.
This is the little piece of code I have
casper.then(function(){
this.waitForText("To", function(){
this.sendKeys("div[aria-label='Message body']","<p>This a message.</p>
<a href='http://example.com'>example.com</a>\n ");
});
this.wait(5000);
});
The main problem is when I send the text to the body message with this.sendKeys()
function of casper, it does send the text to the box where you write the message, but I need the example.com arrive to the body message as a link, I tried passing an <a>
html tag, but it doesn't work as I expected to.
This is another Idea I think to solve the same problem. You know when you're sending a message you can click on the button "insert hyperlink", well with this code, I do the click, it opens a small window where you paste your hyperlink and press ok. This is the code and Do everything just fine.
casper.then(function(){
this.waitForText("To", function(){
this.click('button[title="Insert hyperlink"]');
});
this.wait(5000);
});
casper.then(function(){
this.waitForText("URL",function(){
this.sendKeys("input[role='textbox']","http://example.me");
});
this.wait(5000);
});
casper.then(function(){
this.waitForText("OK",function(){
this.clickLabel("OK");
});
this.wait(5000);
});
The problem is that when the button "OK" is clicked, it does not appear any hyperlink inside the body message. So I think I need to select first the text and then convert to a hyperlink.