1

我正在尝试编写一个硒脚本以在 craiglist 上发布广告。我有如下的 selenium 脚本,其中直接传递了 post 值。

var driver = test.openBrowser();
var selenium = driver.getSelenium();

var timeout = 30000;
selenium.setTimeout(timeout);

var tx = test.beginTransaction();

var step = test.beginStep("Step 1");
selenium.open("https://www.google.co.in/?gws_rd=cr&ei=5I1SUur9EsTirAed8oCgBA");
test.endStep();

test.beginStep("Step 2");
selenium.waitForPageToLoad(60000);
selenium.type("id=gbqfq", "chennai craiglist");
selenium.keyPress("id=gbqfq", "\13");
selenium.click("link=craigslist: chennai (madras) classifieds for jobs, apartments ...");
test.endStep();

test.beginStep("Step 3");
selenium.waitForPageToLoad(60000);
test.endStep();

test.beginStep("Step 4");
selenium.waitForPageToLoad(60000);
selenium.click("link=admin / office");
test.endStep();

test.beginStep("Step 5");
selenium.waitForPageToLoad(60000);
selenium.doubleClick("id=ef");
selenium.click("link=post");
test.endStep();

test.beginStep("Step 6");
selenium.waitForPageToLoad(60000);
selenium.click("name=id");
test.endStep();

test.beginStep("Step 7");
selenium.waitForPageToLoad(60000);
selenium.click("name=go");
test.endStep();

test.beginStep("Step 8");
selenium.waitForPageToLoad(60000);
selenium.click("xpath=//section[@class='body']/form/blockquote/label[2]/input");
test.endStep();

test.beginStep("Step 9");
selenium.waitForPageToLoad(60000);
selenium.type("id=PostingTitle", "Post title ");
selenium.type("id=GeographicArea");
selenium.type("id=GeographicArea", "Post location");
selenium.type("id=PostingBody", "Post description");
selenium.type("id=FromEMail", "replyto@gmail.com");
selenium.type("id=ConfirmEMail", "replyto@gmail.com");
selenium.type("id=compensation", "DOE");
selenium.click("name=go");
test.endStep();

test.beginStep("Step 10");
selenium.waitForPageToLoad(60000);
selenium.click("name=file");
selenium.click("name=go");
selenium.click("xpath=//section[@class='body']//button[.='done with images']");
test.endStep();

test.beginStep("Step 11");
selenium.waitForPageToLoad(60000);
test.endStep();

test.endTransaction();

我尝试将脚本设置为将这些值存储在 CSV 文件中,并从中读取值。我尝试将python与它一起使用。但我失败了。

4

0 回答 0