Write comment in span

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Write comment in span

Noel Glez
I'm found a problem fighting against following code. The problem is I have to write a comment and when I do it manually the comments is written in span. How can I do it? Is it possible?

<div class="_1mwp _1mwq _5bu_ _5yk1">
<div class="_5yk2" tabindex="-2">
<div class="_5rp7">
<div class="_1p1t">
<div class="_1p1v">Escribe algo...</div>
</div>
<div class="_5rpb">
<div class="_5rpu" contenteditable="true" aria-autocomplete="list" aria-expanded="false" aria-haspopup="false" aria-owns="js_18" role="combobox" spellcheck="true" title="Escribe algo...">
<div data-contents="true">
<div class="_45m_ _2vxa" data-block="true" data-offset-key="8g54i-0-0">
<span data-offset-key="8g54i-0-0">
<br data-text="true">
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/4291a424-81a4-4ab6-8952-e16feb22acd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Noel Glez
The code after clicking and write manually is:

<div class="_1mwp _1mwq _5bu_ _5yk1">
<div class="_5yk2" tabindex="-2">
<div class="_5rp7">
<div class="_5rpb">
<div class="_5rpu" contenteditable="true" aria-autocomplete="list" aria-expanded="false" aria-haspopup="false" aria-owns="js_1p" role="combobox" spellcheck="true" title="">
<div data-contents="true">
<div class="_45m_ _2vxa" data-block="true" data-offset-key="8g54i-0-0">
<span data-offset-key="8g54i-0-0">
<span data-text="true">example</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

El miércoles, 27 de enero de 2016, 10:09:53 (UTC+1), Noel Glez escribió:
I'm found a problem fighting against following code. The problem is I have to write a comment and when I do it manually the comments is written in span. How can I do it? Is it possible?

<div class="_1mwp _1mwq _5bu_ _5yk1">
<div class="_5yk2" tabindex="-2">
<div class="_5rp7">
<div class="_1p1t">
<div class="_1p1v">Escribe algo...</div>
</div>
<div class="_5rpb">
<div class="_5rpu" contenteditable="true" aria-autocomplete="list" aria-expanded="false" aria-haspopup="false" aria-owns="js_18" role="combobox" spellcheck="true" title="Escribe algo...">
<div data-contents="true">
<div class="_45m_ _2vxa" data-block="true" data-offset-key="8g54i-0-0">
<span data-offset-key="8g54i-0-0">
<br data-text="true">
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/01bffbb2-8556-42a8-8438-daae8eff95e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Noel Glez
In reply to this post by Noel Glez
The code after clicking and writing manually is:

<div class="_1mwp _1mwq _5bu_ _5yk1">
<div class="_5yk2" tabindex="-2">
<div class="_5rp7">
<div class="_5rpb">
<div class="_5rpu" contenteditable="true" aria-autocomplete="list" aria-expanded="false" aria-haspopup="false" aria-owns="js_1p" role="combobox" spellcheck="true" title="">
<div data-contents="true">
<div class="_45m_ _2vxa" data-block="true" data-offset-key="8g54i-0-0">
<span data-offset-key="8g54i-0-0">
<span data-text="true">example</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1e65465f-0346-4601-9ca4-ce84a7cfd485%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

PeterJeffreyGale .-2
What does the screen actually look like, and what code are you executing to input the text? 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6961bc48-5f98-44e6-af9c-1958c6e22e85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Noel Glez

It is a fb page, see image below:



El miércoles, 27 de enero de 2016, 11:01:55 (UTC+1), PeterJeffreyGale escribió:
What does the screen actually look like, and what code are you executing to input the text? 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/26a5ae6f-924a-488a-aa9a-821c4bd1a9c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

PeterJeffreyGale .-2
And your code?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/41dd61f0-0d6f-4ea6-982e-dfe696bc8cea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Noel Glez
This is the code I use:
html code changes when you do click, because of that I use different xpath. 
// Send message
WebElement msgBox = driver.findElement(By.xpath(".//*[@id='js_5y']/div[2]/div[2]/div"));
        msgBox.click();
WebElement msg = driver.findElement(By.xpath("//*[@id='js_4a']/div[2]/div[2]/div/div/div/div/div/div/div/span/span"));
msg.sendKeys(msgValue);

El miércoles, 27 de enero de 2016, 11:34:07 (UTC+1), PeterJeffreyGale escribió:
And your code?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

PeterJeffreyGale .-2
Have allowed time for the ajax to ginidh after the click?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/948f225f-fef6-4102-9de6-9bc15ae93ed2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Xiang Dong
In reply to this post by Noel Glez
you are not tries to write comment to the span, instead of, the text should be write to parent <div>, <div class="_5rpu" contenteditable="true" aria-autocomplete="list" aria-expanded="false" aria-haspopup="false" aria-owns="js_1p" role="combobox" spellcheck="true" title="">this div is editable.

you can't use sendKeys method for a div because original div is not an editable element, instead of it, you can use Javascript to do it

JavascriptExecutor js = (JavascriptExecutor) webDriver;
String script = "if(document.createEventObject){arguments[0].textContent = '" + data
+ "';} else if(document.createEvent) { arguments[0].textContent='" + data + "';}";
js.executeScript(script, webElement);
Hope it works for you.

Best Regards,
--david


Date: Wed, 27 Jan 2016 14:51:19 -0800
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] Re: Write comment in span

This is the code I use:
html code changes when you do click, because of that I use different xpath. 
// Send message
WebElement msgBox = driver.findElement(By.xpath(".//*[@id='js_5y']/div[2]/div[2]/div"));
        msgBox.click();
WebElement msg = driver.findElement(By.xpath("//*[@id='js_4a']/div[2]/div[2]/div/div/div/div/div/div/div/span/span"));
msg.sendKeys(msgValue);

El miércoles, 27 de enero de 2016, 11:34:07 (UTC+1), PeterJeffreyGale escribió:
And your code?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W222C0AC6510FFEAD9632FA90DA0%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

PeterJeffreyGale .-2
What happens if you just use sendkeys to send your input text to the element identified by the xpath: //*[@title="What\'s on your mind?"]

You might have to sort out escaping for the combination of single and double characters when you put that into your Java code

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1d6b1de5-0948-437a-857f-01d95871f393%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Noel Glez
In reply to this post by Xiang Dong
When I run this script I get:
arguments[0] is undefined

This is my code:

        // Find the text input element by its name
WebElement msgOn = driver.findElement(new ByClassName("_4-fs"));
msgOn.click();
// Send message
WebElement msgBox = driver.findElement(By.xpath("html/body/div[1]/div[2]/div[1]/div/div[3]/div/div[1]/div[2]/div[3]/div[5]/div/div/div/div/div[2]/div/div[2]/div[2]/div"));
JavascriptExecutor js = (JavascriptExecutor) driver;

String script = "if(document.createEventObject){ arguments[0].textContent = '" + msgValue
+ "';} else if(document.createEvent) { arguments[0].textContent = '" + msgValue + "';}";
js.executeScript(script, msgBox);
//BUTTON
WebElement buttonSubmit = driver.findElement(new By.ByCssSelector("._1mf7._4jy0._4jy3._4jy1._51sy.selected._42ft"));
buttonSubmit.click();

El jueves, 28 de enero de 2016, 5:29:54 (UTC+1), David Dong escribió:
you are not tries to write comment to the span, instead of, the text should be write to parent <div>, <div class="_5rpu" contenteditable="true" aria-autocomplete="list" aria-expanded="false" aria-haspopup="false" aria-owns="js_1p" role="combobox" spellcheck="true" title="">this div is editable.

you can't use sendKeys method for a div because original div is not an editable element, instead of it, you can use Javascript to do it

JavascriptExecutor js = (JavascriptExecutor) webDriver;
String script = "if(document.createEventObject){arguments[0].textContent = '" + data
+ "';} else if(document.createEvent) { arguments[0].textContent='" + data + "';}";
js.executeScript(script, webElement);
Hope it works for you.

Best Regards,
--david


Date: Wed, 27 Jan 2016 14:51:19 -0800
From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zJrzWwUeDAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">noelgl...@...
To: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zJrzWwUeDAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com
Subject: [selenium-users] Re: Write comment in span

This is the code I use:
html code changes when you do click, because of that I use different xpath. 
// Send message
WebElement msgBox = driver.findElement(By.xpath(".//*[@id='js_5y']/div[2]/div[2]/div"));
        msgBox.click();
WebElement msg = driver.findElement(By.xpath("//*[@id='js_4a']/div[2]/div[2]/div/div/div/div/div/div/div/span/span"));
msg.sendKeys(msgValue);

El miércoles, 27 de enero de 2016, 11:34:07 (UTC+1), PeterJeffreyGale escribió:
And your code?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zJrzWwUeDAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="zJrzWwUeDAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com?utm_medium\75email\46utm_source\75footer&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com?utm_medium\75email\46utm_source\75footer&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e9496c53-81e0-4eef-94e3-3334d0c3a119%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Noel Glez
In reply to this post by PeterJeffreyGale .-2
I try easy thing like: Hello, Good night... but it's still not working...

msgValue = "Hello";
WebElement msgBox = driver.findElement(By.xpath(".//*[@id='js_5y']/div[2]/div[2]/div"));
        msgBox.click();
WebElement msg = driver.findElement(By.xpath("//*[@id='js_4a']/div[2]/div[2]/div/div/div/div/div/div/div/span/span"));
msg.sendKeys(msgValue);


El jueves, 28 de enero de 2016, 11:12:59 (UTC+1), PeterJeffreyGale escribió:
What happens if you just use sendkeys to send your input text to the element identified by the xpath: //*[@title="What\'s on your mind?"]

You might have to sort out escaping for the combination of single and double characters when you put that into your Java code

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/722caed8-0a14-4cc7-87d9-1eb9991bd835%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Xiang Dong
In reply to this post by Noel Glez
Make sure you find the element properly, you can check does the return element is null or not. BYW, my fault, you can find the <span> and using following script. <span> inherit contenteditable attribute from the div

Best Regards,
--david


Date: Fri, 29 Jan 2016 17:30:28 -0800
From: [hidden email]
To: [hidden email]
Subject: Re: [selenium-users] Re: Write comment in span

When I run this script I get:
arguments[0] is undefined

This is my code:

        // Find the text input element by its name
WebElement msgOn = driver.findElement(new ByClassName("_4-fs"));
msgOn.click();
// Send message
WebElement msgBox = driver.findElement(By.xpath("html/body/div[1]/div[2]/div[1]/div/div[3]/div/div[1]/div[2]/div[3]/div[5]/div/div/div/div/div[2]/div/div[2]/div[2]/div"));
JavascriptExecutor js = (JavascriptExecutor) driver;

String script = "if(document.createEventObject){ arguments[0].textContent = '" + msgValue
+ "';} else if(document.createEvent) { arguments[0].textContent = '" + msgValue + "';}";
js.executeScript(script, msgBox);
//BUTTON
WebElement buttonSubmit = driver.findElement(new By.ByCssSelector("._1mf7._4jy0._4jy3._4jy1._51sy.selected._42ft"));
buttonSubmit.click();

El jueves, 28 de enero de 2016, 5:29:54 (UTC+1), David Dong escribió:
you are not tries to write comment to the span, instead of, the text should be write to parent <div>, <div class="_5rpu" contenteditable="true" aria-autocomplete="list" aria-expanded="false" aria-haspopup="false" aria-owns="js_1p" role="combobox" spellcheck="true" title="">this div is editable.

you can't use sendKeys method for a div because original div is not an editable element, instead of it, you can use Javascript to do it

JavascriptExecutor js = (JavascriptExecutor) webDriver;
String script = "if(document.createEventObject){arguments[0].textContent = '" + data
+ "';} else if(document.createEvent) { arguments[0].textContent='" + data + "';}";
js.executeScript(script, webElement);
Hope it works for you.

Best Regards,
--david


Date: Wed, 27 Jan 2016 14:51:19 -0800
From: [hidden email]
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: Write comment in span

This is the code I use:
html code changes when you do click, because of that I use different xpath. 
// Send message
WebElement msgBox = driver.findElement(By.xpath(".//*[@id='js_5y']/div[2]/div[2]/div"));
        msgBox.click();
WebElement msg = driver.findElement(By.xpath("//*[@id='js_4a']/div[2]/div[2]/div/div/div/div/div/div/div/span/span"));
msg.sendKeys(msgValue);

El miércoles, 27 de enero de 2016, 11:34:07 (UTC+1), PeterJeffreyGale escribió:
And your code?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e9496c53-81e0-4eef-94e3-3334d0c3a119%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W36C804ECFF03453F30CB5890DD0%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Noel Glez

This is the code I tried to get the right element to write in:

//WebElement msgBox = driver.findElement(By.xpath("html/body/div[1]/div[2]/div[1]/div/div[3]/div/div[1]/div[2]/div[3]/div[5]/div/div/div/div/div[2]/div/div[2]/div[2]/div/div/div/div/div/div/div/span/span"));
//WebElement msgBox = driver.findElement(By.xpath("html/body/div[1]/div[2]/div[1]/div/div[3]/div/div[1]/div[2]/div[3]/div[5]/div/div/div/div/div[2]/div/div[2]/div[2]/div/div/div/div[2]/div/div/div"));
//WebElement msgBox = driver.findElement(By.xpath("html/body/div[1]/div[2]/div[1]/div/div[3]/div/div[1]/div[2]/div[3]/div[5]/div/div/div/div/div[2]/div/div[2]/div[2]/div"));

Any idea of what I'm doing wrong? 

Thanks for your time,
Noel


El domingo, 31 de enero de 2016, 14:13:57 (UTC+1), David Dong escribió:
Make sure you find the element properly, you can check does the return element is null or not. BYW, my fault, you can find the <span> and using following script. <span> inherit contenteditable attribute from the div

Best Regards,
--david


Date: Fri, 29 Jan 2016 17:30:28 -0800
From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="e95A7lsmDQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">noelgl...@...
To: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="e95A7lsmDQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com
Subject: Re: [selenium-users] Re: Write comment in span

When I run this script I get:
arguments[0] is undefined

This is my code:

        // Find the text input element by its name
WebElement msgOn = driver.findElement(new ByClassName("_4-fs"));
msgOn.click();
// Send message
WebElement msgBox = driver.findElement(By.xpath("html/body/div[1]/div[2]/div[1]/div/div[3]/div/div[1]/div[2]/div[3]/div[5]/div/div/div/div/div[2]/div/div[2]/div[2]/div"));
JavascriptExecutor js = (JavascriptExecutor) driver;

String script = "if(document.createEventObject){ arguments[0].textContent = '" + msgValue
+ "';} else if(document.createEvent) { arguments[0].textContent = '" + msgValue + "';}";
js.executeScript(script, msgBox);
//BUTTON
WebElement buttonSubmit = driver.findElement(new By.ByCssSelector("._1mf7._4jy0._4jy3._4jy1._51sy.selected._42ft"));
buttonSubmit.click();

El jueves, 28 de enero de 2016, 5:29:54 (UTC+1), David Dong escribió:
you are not tries to write comment to the span, instead of, the text should be write to parent <div>, <div class="_5rpu" contenteditable="true" aria-autocomplete="list" aria-expanded="false" aria-haspopup="false" aria-owns="js_1p" role="combobox" spellcheck="true" title="">this div is editable.

you can't use sendKeys method for a div because original div is not an editable element, instead of it, you can use Javascript to do it

JavascriptExecutor js = (JavascriptExecutor) webDriver;
String script = "if(document.createEventObject){arguments[0].textContent = '" + data
+ "';} else if(document.createEvent) { arguments[0].textContent='" + data + "';}";
js.executeScript(script, webElement);
Hope it works for you.

Best Regards,
--david


Date: Wed, 27 Jan 2016 14:51:19 -0800
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] Re: Write comment in span

This is the code I use:
html code changes when you do click, because of that I use different xpath. 
// Send message
WebElement msgBox = driver.findElement(By.xpath(".//*[@id='js_5y']/div[2]/div[2]/div"));
        msgBox.click();
WebElement msg = driver.findElement(By.xpath("//*[@id='js_4a']/div[2]/div[2]/div/div/div/div/div/div/div/span/span"));
msg.sendKeys(msgValue);

El miércoles, 27 de enero de 2016, 11:34:07 (UTC+1), PeterJeffreyGale escribió:
And your code?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com?utm_medium\75email\46utm_source\75footer&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com?utm_medium\75email\46utm_source\75footer&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/6c8e380e-99fb-43e0-8316-88ca4370a992%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="e95A7lsmDQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="e95A7lsmDQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/e9496c53-81e0-4eef-94e3-3334d0c3a119%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/e9496c53-81e0-4eef-94e3-3334d0c3a119%40googlegroups.com?utm_medium\75email\46utm_source\75footer&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/e9496c53-81e0-4eef-94e3-3334d0c3a119%40googlegroups.com?utm_medium\75email\46utm_source\75footer&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/e9496c53-81e0-4eef-94e3-3334d0c3a119%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1b691210-23e4-4143-9a48-8b2387466463%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

PeterJeffreyGale .-2
Did you try my last suggestion?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/542fb0c2-55c1-4da8-ae1e-8605990933f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

PeterJeffreyGale .-2
In reply to this post by Noel Glez
Did you try my last suggestion?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/709f63d4-1b40-488b-aabb-79841aec6d45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Noel Glez
Yes, I did. It's a script tag. Check please the source code of this page:

https://www.facebook.com/Galicia-Alive-1405896593013485

My code is:
        // Find the text input element by its name
WebElement msgOn = driver.findElement(new ByClassName("_4-fs"));
msgOn.click();
// Send message
WebElement msgBox = driver.findElement(By.xpath("//*[@title=\"Escribe algo...\""));
JavascriptExecutor js = (JavascriptExecutor) driver;
String script = "if(document.createEventObject){ arguments[0].textContent = '" + msgValue
+ "';} else if(document.createEvent) { arguments[0].textContent = '" + msgValue + "';}";
js.executeScript(script, msgBox); I got this error: Exception in thread "AWT-EventQueue-0" org.openqa.selenium.InvalidSelectorException: The given selector //*[@title="Escribe algo..." is either invalid or does not result in a WebElement. The following error occurred: InvalidSelectorError: Unable to locate an element with the xpath expression //*[@title="Escribe algo..." because of the following error: SyntaxError: The expression is not a legal expression.

El miércoles, 3 de febrero de 2016, 1:03:12 (UTC+1), PeterJeffreyGale escribió:
Did you try my last suggestion?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/31f30edf-921b-4181-aaaa-554f931fe461%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

PeterJeffreyGale .-2
That's not what I suggested. You shouldn't need to use JavaScript.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/8a239007-f84e-4834-b083-a68730091e02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

Noel Glez
That one?
"Make sure you find the element properly, you can check does the return element is null or not. BYW, my fault, you can find the <span> and using following script. <span> inherit contenteditable attribute from the div"

Could you be more specific, please?


El miércoles, 3 de febrero de 2016, 23:56:24 (UTC+1), PeterJeffreyGale escribió:
That's not what I suggested. You shouldn't need to use JavaScript.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/a2490613-883f-421c-b1b2-28e4a97ac8d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Write comment in span

PeterJeffreyGale .-2
You are quoting David ... who are you expecting to answer?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/807c785c-18e9-4840-bf05-eee2d272d856%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
12