如何复制和粘贴selenium Webdriver中的内容?

问题描述:

任何人都可以请指导我如何从一个站点复制内容并在selenium WebDriver的帮助下迁移到另一端?如何复制和粘贴selenium Webdriver中的内容?

要清楚,你想执行一个网站目录复制/粘贴到另一个文件夹?

或者你想解析html内容,并将其保存在外部文件中?

前者并不是真正的硒友好型。

+0

我只是想从一个网站到另一个网站的形式发布数据,并提交相同。 –

所以,你想要什么一个简单的例子是这样的:

网站1:

<span id="spanID"> content in here </span> 

网站2:

<form id="inputID"> [ you want content in here ] </form> 

请注意伪HTML。

你需要为了使这项工作是做什么..

browser.get("http://www.website1.com); 

    var tempElement = $("spanID"); 
    tempElement .getText().then(function (contentOfSpan) { 
       console.log(contentOfSpan); // will print the content of the span... now you want to save this value somewhere in your scope. 
    }); 
    ///////////////////////////////////////////////// 
    browser.get("http://www.website2.com); 

    var tempElement = $("inputID"); 
    tempElement.sendKeys(RefferenceTocontentOfSpan)