Robin Becker wrote:
We're making tests for an application which allows the user to copy a spreadsheet from an excel workbook and paste it into a text area. This causes problems for selenium as the tabs and other formatting information don't seem easy to enter in html.

Has anyone already solved this kind of problem? I am groping towards using javascript to set the td text from a string containing '\t', '\n', '\r' characters. Would that work?
My final  solution to this problem was as follows.

1) modify the htmlutils.js to make getText look for a special attribute on the 
TD

function getText(element) {
    text = "";
    if(element.seleniumEncodedContent){
                text = decodeURI(element.seleniumEncodedContent);
                return text;
                }
    if(element.textContent) {
        text = element.textContent;
    } else if(element.innerText) {
        text = element.innerText;
    }
        // Replace   with a space
        // TODO - should this be in the match() code instead?
        text = text.replace(/\240/g, " ");
    return text.trim();
}

2) modify the table html so that we run an onload to set up the individual TD
the function to do that looks like

function setup(id,t){
        var e = document.getElementById(id);
        e.seleniumEncodedContent = encodeURI(t);
        if(document.all) e.innerHTML = '<pre>'+t+'</pre>';
        else{
                var 
n=document.createElement('pre').appendChild(document.createTextNode(t));
                if(e.firstChild) e.replaceChild(n,e.firstChild);
                else e.appendChild(n);
                }
        }

this allows at least some of the text to be shown reasonably

--
Robin Becker
_______________________________________________
Selenium-users mailing list
Selenium-users@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users

Reply via email to