Closed ayyobro closed 9 years ago
I think this is a question for my plugin rather than the se-builder package, so you can close this here and open it in my repo: https://github.com/sschwartzman/newrelic-synthetics-sebuilder/issues
Thanks, Seth
On second thought, this is 2 separate issues. The "Preferences.getString" one is unrelated to the output you see the "timeout error". According to @ayyobro, he sees this "Preferences.getString" error no matter what formate he's exporting in, so it's not related to my plugin. Is that something you guys can help him with?
Thanks and sorry for the confusion, Seth
AFAIK this is a bug that got fixed in v2.3.3. Can you check you're all the way up to date?
I have same issue, just installed yesterday from the latest xpi (http://www.saucelabs.com/addons/selenium-builder-latest.xpi). I'm unable to save or export my script. It does allow me to run it via "OnSauce demand". What should we do?
@Zarkonnen I installed the latest xpi and encountered the same issue. Now I'm stuck. Can we downgrade to older .xpi? Where can they be found?
It appears that the "latest" xpi link points to 2.3.1 - I've tried blowing away my plugin install and reinstalling from that xpi. To get around it, I cloned the repo, and copied the "seleniumbuilder" folder to the firefox extensions directory as "seleniumbuilder@saucelabs.com". @ayyobro @buch0090
Just had a look at this, there's two related problems:
Sorry for the inconvenience!
Got the error: TypeError: Preferences.getString whenever I try to export a script from the se-builder.
Here's the steps:
After that, I get the error. Here's the script I pasted into synthetics ( i was able to export to github just fine once I connected that account to selenium ):
/**
/\ CONFIGURATIONS **/
// Script-wide timeout for wait and waitAndFind functions (in ms) var DefaultTimeout = 10000; // Change to any User Agent you want to use. // Leave as "default" or empty to use the Synthetics default. var UserAgent = "default";
/\ HELPER FUNCTIONS **/
var assert = require('assert'), By = $driver.By, startTime = new Date(), thisStep = 0, VARS = {}; var log = function(msg) { var elapsedSecs = (new Date() - startTime) / 1000.0; console.log('Step ' + thisStep + ': ' + elapsedSecs.toFixed(1) + 's: ' + msg); thisStep++; }; // 1st log is sometimes ignored for some reason, so this is a dummy log('init'); function isAlertPresent() { try { var thisAlert = $browser.switchTo().alert(); return true; } catch (err) { return false; } } function isElementSelected(el) { return $browser.findElement(el).isSelected(); } function isTextPresentIn(text, sourceEl) { return sourceEl.getText() .then(function (wholetext) { log("Assert Text Present: '" + text +"'"); assert.notEqual(wholetext.indexOf(text), -1, "Text Not Found: '" + text + "'"); }); }
function isTextPresent(text) { return isTextPresentIn(text, $browser.findElement(By.tagName('html'))); }
/\ BEGINNING OF SCRIPT **/
// Setting User Agent is not then-able, so we do this first (if defined and not default) if ((typeof UserAgent !== 'undefined') && (UserAgent != 'default')) { $browser.addHeader('User-Agent', UserAgent); log('Setting User-Agent to ' + UserAgent); }
// Get browser capabilities and do nothing with it, so that we start with a then-able command $browser.getCapabilities().then(function () { })
.then(function () { log('get "http://localhost:8000/twenty-sixteen-conference"'); return $browser.get("http://localhost:8000/twenty-sixteen-conference"); })
.then(function () { log('setElementText "company_name"'); return $browser.waitForAndFindElement(By.name("company_name"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("Nick Company 1"); })
.then(function () { log('setElementText "company_address"'); return $browser.waitForAndFindElement(By.name("company_address"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("123 Whatever Drive"); })
.then(function () { log('setElementText "company_city"'); return $browser.waitForAndFindElement(By.name("company_city"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("Indianapolis"); })
.then(function () { log('setElementSelected "//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[1]"'); return $browser.waitForAndFindElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[1]"), DefaultTimeout); }) .then(function(el) { return el.isSelected(); }) .then(function(bool) { if (!bool) { $browser.actions().click($browser.findElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[1]"))).perform(); } })
.then(function () { log('setElementSelected "//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[15]"'); return $browser.waitForAndFindElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[15]"), DefaultTimeout); }) .then(function(el) { return el.isSelected(); }) .then(function(bool) { if (!bool) { $browser.actions().click($browser.findElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[15]"))).perform(); } })
.then(function () { log('setElementSelected "//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[15]"'); return $browser.waitForAndFindElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[15]"), DefaultTimeout); }) .then(function(el) { return el.isSelected(); }) .then(function(bool) { if (!bool) { $browser.actions().click($browser.findElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[15]"))).perform(); } })
.then(function () { log('setElementSelected "//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[15]"'); return $browser.waitForAndFindElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[15]"), DefaultTimeout); }) .then(function(el) { return el.isSelected(); }) .then(function(bool) { if (!bool) { $browser.actions().click($browser.findElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[4]/div/select//option[15]"))).perform(); } })
.then(function () { log('setElementText "company_zip"'); return $browser.waitForAndFindElement(By.name("company_zip"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("46237"); })
.then(function () { log('setElementText "company_website"'); return $browser.waitForAndFindElement(By.name("company_website"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("http"); })
.then(function () { log('setElementText "company_website"'); return $browser.waitForAndFindElement(By.name("company_website"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("http://b-y.net"); })
.then(function () { log('setElementSelected "//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[8]/div/select//option[1]"'); return $browser.waitForAndFindElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[8]/div/select//option[1]"), DefaultTimeout); }) .then(function(el) { return el.isSelected(); }) .then(function(bool) { if (!bool) { $browser.actions().click($browser.findElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[8]/div/select//option[1]"))).perform(); } })
.then(function () { log('setElementSelected "//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[8]/div/select//option[3]"'); return $browser.waitForAndFindElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[8]/div/select//option[3]"), DefaultTimeout); }) .then(function(el) { return el.isSelected(); }) .then(function(bool) { if (!bool) { $browser.actions().click($browser.findElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[8]/div/select//option[3]"))).perform(); } })
.then(function () { log('setElementSelected "//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[9]/div/select//option[2]"'); return $browser.waitForAndFindElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[9]/div/select//option[2]"), DefaultTimeout); }) .then(function(el) { return el.isSelected(); }) .then(function(bool) { if (!bool) { $browser.actions().click($browser.findElement(By.xpath("//div[1]/form[1]/div[1]/div/div[2]/fieldset/div[1]/div[9]/div/select//option[2]"))).perform(); } })
.then(function () { log('setElementText "conference_contact_name"'); return $browser.waitForAndFindElement(By.name("conference_contact_name"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("Nick Tester"); })
.then(function () { log('setElementText "conference_contact_email"'); return $browser.waitForAndFindElement(By.name("conference_contact_email"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("nickconf1@gmail.com"); })
.then(function () { log('setElementText "attendee_one_name"'); return $browser.waitForAndFindElement(By.name("attendee_one_name"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("Nick Bester"); })
.then(function () { log('setElementText "attendee_one_email"'); return $browser.waitForAndFindElement(By.name("attendee_one_email"), DefaultTimeout); }) .then(function (el) { el.clear(); el.sendKeys("besttester@gmail.com"); })
.then(function () { log('clickElement "input.btn.btn-primary-green"'); return $browser.waitForAndFindElement(By.css("input.btn.btn-primary-green"), DefaultTimeout); }) .then(function (el) { $browser.actions().click(el).perform(); })
.then(function() { log('Browser script execution SUCCEEDED.'); }, function(err) { log ('Browser script execution FAILED.'); throw(err); });
/\ END OF SCRIPT **/
Here is also the error log that I got back from synthetics on newrelic.com: Step 0: 0.0s: init Step 1: 0.0s: get "http://localhost:8000/twenty-sixteen-conference" Step 2: 0.1s: setElementText "company_name" Step 3: 10.2s: Browser script execution FAILED. Error: Timed-out waiting for element to be located using: By.name("company_name") Wait timed out after 10042ms at /opt/minion/nodemodules/selenium-webdriver/lib/webdriver/promise.js:1630:20 at promise.ControlFlow.runInFrame (/opt/minion/nodemodules/selenium-webdriver/lib/webdriver/promise.js:1877:20) at promise.Callback.goog.defineClass.notify (/opt/minion/nodemodules/selenium-webdriver/lib/webdriver/promise.js:2464:25) at promise.Promise.notify (/opt/minion/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12) at Array.forEach (native) at Object.goog.array.forEach (/opt/minion/nodemodules/selenium-webdriver/lib/goog/array/array.js:203:43) at promise.Promise.notifyAll (/opt/minion/node_modules/selenium-webdriver/lib/webdriver/promise.js:552:16) at goog.async.run.processWorkQueue (/opt/minion/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21) at runMicrotasksCallback (node.js:337:7) at process._tickCallback (node.js:355:11) From: Task: Timed-out waiting for element to be located using: By.name("company_name") at promise.ControlFlow.wait (/opt/minion/node_modules/selenium-webdriver/lib/webdriver/promise.js:1617:15) at webdriver.WebDriver.wait (/opt/minion/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:714:21) at syntheticsDriverPrototype.waitForElement.value as waitForElement at syntheticsDriverPrototype.waitForAndFindElement.value as waitForAndFindElement at eval (eval at (/opt/minion/nodemodules/synthetics-runner/lib/resource/job-resource.js:387:19), :85:19)
at promise.ControlFlow.runInFrame (/opt/minion/nodemodules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
at promise.Callback.goog.defineClass.notify (/opt/minion/nodemodules/selenium-webdriver/lib/webdriver/promise.js:2464:25)
at promise.Promise.notify (/opt/minion/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)
at Array.forEach (native)
at Object.goog.array.forEach (/opt/minion/nodemodules/selenium-webdriver/lib/goog/array/array.js:203:43)
at promise.Promise.notifyAll (/opt/minion/node_modules/selenium-webdriver/lib/webdriver/promise.js:552:16)