What exactly should be done to redirect back to an angular page? This is my input & button from html (non-angular page)
要重定向到有棱角的页面,究竟应该做些什么?这是来自html的输入和按钮(非角页面)
<input class="value" type="password" 3dsinput="password" name="password">
<input type="submit" value="Submit" name="submit" alt="Submit" border="0">
located in todo-spec.js like this;
位于todo-spec。js这样;
element(by.css('.value')).sendKeys('12345');
element(by.buttonText('Submit')).click();
with browser.driver.ignoreSynchronization = true;
called last on the previous angular page to turn off synchronization. Keep in mind this little page communicates with a payment gateway service before it redirects the user to oncoming angular pages. I've tried to switch off synchronization but to no relief.
browser.driver。ignoreSynchronization = true;在前一个角页上调用最后关闭同步。请记住,这个小页面在将用户重定向到即将到来的角度页面之前,会与支付网关服务进行通信。我尝试过关闭同步,但毫无效果。
Also to note: I seem to be getting two different errors whenever I run the same EXACT SCRIPT minute after minute. My guess is it's something to do with timeout. One is;
同样要注意的是:当我一分钟一分钟地运行相同的脚本时,我似乎得到了两个不同的错误。我猜这和超时有关。一个是;
Failed: Cannot assign to read only property 'stack' of Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
失败:在等待量角器与页面同步时,不能分配只读属性“栈”的错误。角是未定义的。这可能是因为这是一个无角页面,也可能是因为您的测试涉及客户端导航,这会干扰量角器的自举。见http://git。io / v4gXM细节”
and the other;
和其他;
Failed: javascript error: document unloaded while waiting for result (Session info: chrome=51.0.2704.84) (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 1.40 seconds Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42' System info: host: 'xxxxxxxx', ip: 'xxxxx', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4), userDataDir=C:\Users\Colin\AppData\Local\Temp\scoped_dir6892_17447}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=51.0.2704.84, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: fde99ca463aacd06f923cae8895b06a5
失败:javascript错误:文件卸载在等待结果(会话信息:chrome = 51.0.2704.84)(司机信息:chromedriver = 2.21.371459(36 d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),平台= Windows NT 10.0 x86_64)(警告:服务器没有提供任何异常堆栈信息)命令持续时间或超时:1.40秒构建信息:版本:“2.52.0”,修订:4 c2593c,时间:2016-02-11 19:06:42的系统信息:主持人:' xxxxxxxx ',ip:xxxxx,os.name:“Windows 10”,操作系统。拱:amd64,操作系统。版本:10.0,java。版本:“1.8.0_92”驱动信息:org.openqa.selenium.chrome。ChromeDriver功能[{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371459 (36d3d07f660bcf1bff28a75d1cdabed93\ 83\数量73\版本警报)webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javastenabled =true, cssSelectorsEnabled=true}会话ID: fde99ca463aacd06f923cae8895b06a5。
Your help shall be highly appreciated...
非常感谢您的帮助。
2 个解决方案
#1
2
Solved. I'm probably repeating the same solution (suggested by others) that I simply misunderstood with other SO similar issues.
解决了。我可能在重复同样的解决方案(别人建议的),我只是误解了其他类似的问题。
I had to use
browser.driver.sleep(5000)
on non-angular page to ensure it loads in and settles properly and that protractor does not quickly run over it.我必须使用浏览器。driver.sleep(5000)在非角页面上,以确保它装入并正确地安顿下来,量角器不会很快超过它。
To manage jasmine timeouts (which was an occasional issue - making me feel like I was the wrong one all along), I explicitly programmed the timeout
in the beforeEach
function at the top. Take a look;
为了管理jasmine超时(这是一个偶然的问题——让我觉得我一直都是错的),我在最上面的beforeEach函数中显式地设置了超时。看一看;
The beforeEach as seen here (Setting defaultTimeoutInterval
in config.js did not work for me.)
这里看到的beforeEach(在配置中设置defaultTimeoutInterval)。js对我没用。
describe('angularjs homepage todo list', function() {
beforeEach(function (done) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 80000;
setTimeout(function () {
// console.log('inside timeout');
done();
}, 500);
});
it ('should be bla bla bla', function(){
Other section in the describe-it function (angular>>non-angular>>angular)
描述函数的其他部分(角>>非角>>角)
browser.ignoreSynchronization = true; // Turn sync off before submit (on angular page).
this_page.clickBtn(); //Redirect to *NON-ANGULAR PAGE*
//*NON-ANGULAR PAGE* loaded (payment gateway)
browser.driver.sleep(5000);// to fully load non-angular page
element(by.css('.value')).sendKeys('12345');
element(by.buttonText('Submit')).click();
Again I stand to be corrected if anyone feels different about this. Took me a week of up and down frustration to figure this bit out. - New 'protractorer' ;)
如果有人对这件事有不同的看法,我将会被纠正。我花了整整一个星期的时间才弄明白这一点。-新量角器的;
Also BONUS VERY IMPORTANT if you ever run into angular check boxes and radio buttons, explicitly use;
另外,如果你遇到有角的复选框和单选按钮,也可以明确地使用;
var elm = element(by.id('drop-off'));
browser.executeScript("arguments[0].click();", elm.getWebElement());
instead of just
而不是仅仅
element(by.id('drop-off')).click();
For some reason, materialize, with its design, hides the raw element in the check-box / radio button making you over look it as protractor/webdriver will not detect an error. So you need to be very aware of that to help with talking to the backend. Tiny but big issue I spotted late. When I figured this, my protractor tests ran as smooth as a baby's butt ;)
出于某种原因,通过它的设计,materialize将原始元素隐藏在复选框/单选按钮中,使您可以在pro拖拉机/webdriver不会检测到错误时查看它。所以你需要非常清楚这一点,以帮助与后端对话。我最近发现了一个虽小但很重要的问题。当我想到这一点时,我的量角器测试就像婴儿的屁股一样光滑;
One more thing that greatly helped me was paying attention to webdriver errors (which I was not doing before). They were more explicit than the protractor ones.
另一件对我有很大帮助的事情是关注webdriver错误(我以前没有这么做过)。它们比量角器更明显。
#2
0
After the click, I would wait to be redirected to the desired page (waiting for a specific part of URL to be present in the current URL), turn the sync on again and issue waitForAngular()
:
单击之后,我将等待被重定向到所需的页面(等待URL的特定部分出现在当前URL中),再次打开同步并发出waitfor():
browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /index/.test(url); // TODO: replace "index" with a relevant part of URL in your case
});
}).then(function () {
browser.ignoreSynchronization = true;
browser.waitForAngular();
});
#1
2
Solved. I'm probably repeating the same solution (suggested by others) that I simply misunderstood with other SO similar issues.
解决了。我可能在重复同样的解决方案(别人建议的),我只是误解了其他类似的问题。
I had to use
browser.driver.sleep(5000)
on non-angular page to ensure it loads in and settles properly and that protractor does not quickly run over it.我必须使用浏览器。driver.sleep(5000)在非角页面上,以确保它装入并正确地安顿下来,量角器不会很快超过它。
To manage jasmine timeouts (which was an occasional issue - making me feel like I was the wrong one all along), I explicitly programmed the timeout
in the beforeEach
function at the top. Take a look;
为了管理jasmine超时(这是一个偶然的问题——让我觉得我一直都是错的),我在最上面的beforeEach函数中显式地设置了超时。看一看;
The beforeEach as seen here (Setting defaultTimeoutInterval
in config.js did not work for me.)
这里看到的beforeEach(在配置中设置defaultTimeoutInterval)。js对我没用。
describe('angularjs homepage todo list', function() {
beforeEach(function (done) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 80000;
setTimeout(function () {
// console.log('inside timeout');
done();
}, 500);
});
it ('should be bla bla bla', function(){
Other section in the describe-it function (angular>>non-angular>>angular)
描述函数的其他部分(角>>非角>>角)
browser.ignoreSynchronization = true; // Turn sync off before submit (on angular page).
this_page.clickBtn(); //Redirect to *NON-ANGULAR PAGE*
//*NON-ANGULAR PAGE* loaded (payment gateway)
browser.driver.sleep(5000);// to fully load non-angular page
element(by.css('.value')).sendKeys('12345');
element(by.buttonText('Submit')).click();
Again I stand to be corrected if anyone feels different about this. Took me a week of up and down frustration to figure this bit out. - New 'protractorer' ;)
如果有人对这件事有不同的看法,我将会被纠正。我花了整整一个星期的时间才弄明白这一点。-新量角器的;
Also BONUS VERY IMPORTANT if you ever run into angular check boxes and radio buttons, explicitly use;
另外,如果你遇到有角的复选框和单选按钮,也可以明确地使用;
var elm = element(by.id('drop-off'));
browser.executeScript("arguments[0].click();", elm.getWebElement());
instead of just
而不是仅仅
element(by.id('drop-off')).click();
For some reason, materialize, with its design, hides the raw element in the check-box / radio button making you over look it as protractor/webdriver will not detect an error. So you need to be very aware of that to help with talking to the backend. Tiny but big issue I spotted late. When I figured this, my protractor tests ran as smooth as a baby's butt ;)
出于某种原因,通过它的设计,materialize将原始元素隐藏在复选框/单选按钮中,使您可以在pro拖拉机/webdriver不会检测到错误时查看它。所以你需要非常清楚这一点,以帮助与后端对话。我最近发现了一个虽小但很重要的问题。当我想到这一点时,我的量角器测试就像婴儿的屁股一样光滑;
One more thing that greatly helped me was paying attention to webdriver errors (which I was not doing before). They were more explicit than the protractor ones.
另一件对我有很大帮助的事情是关注webdriver错误(我以前没有这么做过)。它们比量角器更明显。
#2
0
After the click, I would wait to be redirected to the desired page (waiting for a specific part of URL to be present in the current URL), turn the sync on again and issue waitForAngular()
:
单击之后,我将等待被重定向到所需的页面(等待URL的特定部分出现在当前URL中),再次打开同步并发出waitfor():
browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /index/.test(url); // TODO: replace "index" with a relevant part of URL in your case
});
}).then(function () {
browser.ignoreSynchronization = true;
browser.waitForAngular();
});