0

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.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Gerardo Cordero
  • 164
  • 4
  • 14
  • When I open the email, in the message body you can see the

    and tags, it does escape the code. I need that does not escape the code, so the tags work fine.
    – Gerardo Cordero Jul 29 '16 at 18:22
  • Ok! I don't have an OWA server, and the app is pretty simple, just send a mail message with a Hyperlink. I am just playing around with the CasperJS and SlimerJS, testing all their power, just for curiosity and learn CasperJS. Thank you again, friend. – Gerardo Cordero Jul 29 '16 at 18:38
  • I just open an outlook account in outlook.com, and then try to click in "New" to send a message, and then fill all the form, then click on "Send" and send the message to myself. – Gerardo Cordero Jul 29 '16 at 18:42
  • Well, that's something completely different. – Artjom B. Jul 29 '16 at 18:43
  • Now, as for your problem. Are you sure that there isn't a button in the UI to add a hyperlink? – Artjom B. Jul 29 '16 at 18:44
  • Yes, there is a button in the UI to add a hyperlink. I put that inside this question. But I find another problem with that possible solution. – Gerardo Cordero Jul 29 '16 at 18:46

0 Answers0