Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions examples/Protractor.Samples/Protractor.Samples-NET40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -38,13 +40,11 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="WebDriver, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Selenium.WebDriver.3.0.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
<Reference Include="WebDriver, Version=3.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Selenium.WebDriver.3.4.0\lib\net40\WebDriver.dll</HintPath>
</Reference>
<Reference Include="WebDriver.Support, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Selenium.Support.3.0.0\lib\net40\WebDriver.Support.dll</HintPath>
<Private>True</Private>
<Reference Include="WebDriver.Support, Version=3.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Selenium.Support.3.4.0\lib\net40\WebDriver.Support.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -87,11 +87,11 @@
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Selenium.WebDriver.ChromeDriver.2.25.0.8\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Selenium.WebDriver.ChromeDriver.2.25.0.8\build\Selenium.WebDriver.ChromeDriver.targets'))" />
<Error Condition="!Exists('..\..\packages\Selenium.WebDriver.IEDriver.3.0.0.1\build\Selenium.WebDriver.IEDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Selenium.WebDriver.IEDriver.3.0.0.1\build\Selenium.WebDriver.IEDriver.targets'))" />
<Error Condition="!Exists('..\..\packages\Selenium.Firefox.WebDriver.0.13.0\build\Selenium.Firefox.WebDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Selenium.Firefox.WebDriver.0.13.0\build\Selenium.Firefox.WebDriver.targets'))" />
<Error Condition="!Exists('..\..\packages\Selenium.Firefox.WebDriver.0.17.0\build\Selenium.Firefox.WebDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Selenium.Firefox.WebDriver.0.17.0\build\Selenium.Firefox.WebDriver.targets'))" />
</Target>
<Import Project="..\..\packages\Selenium.WebDriver.ChromeDriver.2.25.0.8\build\Selenium.WebDriver.ChromeDriver.targets" Condition="Exists('..\..\packages\Selenium.WebDriver.ChromeDriver.2.25.0.8\build\Selenium.WebDriver.ChromeDriver.targets')" />
<Import Project="..\..\packages\Selenium.WebDriver.IEDriver.3.0.0.1\build\Selenium.WebDriver.IEDriver.targets" Condition="Exists('..\..\packages\Selenium.WebDriver.IEDriver.3.0.0.1\build\Selenium.WebDriver.IEDriver.targets')" />
<Import Project="..\..\packages\Selenium.Firefox.WebDriver.0.13.0\build\Selenium.Firefox.WebDriver.targets" Condition="Exists('..\..\packages\Selenium.Firefox.WebDriver.0.13.0\build\Selenium.Firefox.WebDriver.targets')" />
<Import Project="..\..\packages\Selenium.Firefox.WebDriver.0.17.0\build\Selenium.Firefox.WebDriver.targets" Condition="Exists('..\..\packages\Selenium.Firefox.WebDriver.0.17.0\build\Selenium.Firefox.WebDriver.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
6 changes: 3 additions & 3 deletions examples/Protractor.Samples/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<packages>
<package id="NUnit" version="2.6.4" targetFramework="net40" />
<package id="PhantomJS" version="2.1.1" targetFramework="net40" />
<package id="Selenium.Firefox.WebDriver" version="0.13.0" targetFramework="net40" />
<package id="Selenium.Support" version="3.0.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="3.0.0" targetFramework="net40" />
<package id="Selenium.Firefox.WebDriver" version="0.17.0" targetFramework="net40" />
<package id="Selenium.Support" version="3.4.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="3.4.0" targetFramework="net40" />
<package id="Selenium.WebDriver.ChromeDriver" version="2.25.0.8" targetFramework="net40" />
<package id="Selenium.WebDriver.IEDriver" version="3.0.0.1" targetFramework="net40" />
<package id="Selenium.WebDriver.MicrosoftWebDriver" version="10.0.14393.0" targetFramework="net40" />
Expand Down
62 changes: 46 additions & 16 deletions src/Protractor/ClientSideScripts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,21 @@ function trySelector(selector) {
}
}
}
function tryBackup() {
return tryEl(document.body) ||
trySelector('[ng-app]') || trySelector('[ng\\:app]') ||
trySelector('[ng-controller]') || trySelector('[ng\\:controller]');
}

if (selector) {
return trySelector(selector);
/* in Hybrid NG mode, the root element by default might not return anything.
* so try the backup stuff as well */
elhooks = trySelector(selector);
if ('undefined' === typeof elhooks) {
return tryBackup();
} else {
return elhooks;
}
} else if (window.__TESTABILITY__NG1_APP_ROOT_INJECTOR__) {
var $injector = window.__TESTABILITY__NG1_APP_ROOT_INJECTOR__;
var $$testability = null;
Expand All @@ -61,9 +73,7 @@ function trySelector(selector) {
} catch (e) {}
return {$injector: $injector, $$testability: $$testability};
} else {
return tryEl(document.body) ||
trySelector('[ng-app]') || trySelector('[ng\\:app]') ||
trySelector('[ng-controller]') || trySelector('[ng\\:controller]');
return tryBackup();
}
};
";
Expand All @@ -78,7 +88,10 @@ function trySelector(selector) {
public const string WaitForAngular = GetNg1HooksHelper + @"
var rootSelector = arguments[0];
var callback = arguments[1];
if (window.angular && !(window.angular.version && window.angular.version.major > 1)) {
if (window.angular
&& !(window.angular.version
&& window.angular.version.major > 1)
) {
/* ng1 */
var hooks = getNg1Hooks(rootSelector);
if (hooks.$$testability) {
Expand All @@ -90,8 +103,8 @@ function trySelector(selector) {
throw new Error('Could not automatically find injector on page: ""' +
window.location.toString() + '"". Consider setting rootElement');
} else {
throw new Error('root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
throw new Error('root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
}
} else if (rootSelector && window.getAngularTestability) {
var el = document.querySelector(rootSelector);
Expand Down Expand Up @@ -124,18 +137,25 @@ function trySelector(selector) {

/**
* Tests whether the angular global variable is present on a page.
*
* Retries in case the page is just loading slowly.
* arguments[0] {number} attempts Number of times to retry.
* arguments[1] {boolean} ng12Hybrid Flag set if app is a hybrid of angular 1 and 2
* arguments[2] {function({version: ?number, message: ?string})} asyncCallback callback
*
*/
public const string TestForAngular = @"
var asyncCallback = arguments[0];
var attempts = arguments[0];
var ng12Hybrid = arguments[1];
var asyncCallback = arguments[2];
var callback = function(args) {
setTimeout(function() {
asyncCallback(args);
}, 0);
};
var definitelyNg1 = false;
var definitelyNg1 = !!ng12Hybrid;
var definitelyNg2OrNewer = false;
var check = function() {
var check = function(n) {
/* Figure out which version of angular we're waiting on */
if (!definitelyNg1 && !definitelyNg2OrNewer) {
if (window.angular && !(window.angular.version && window.angular.version.major > 1)) {
Expand All @@ -147,21 +167,31 @@ function trySelector(selector) {
/* See if our version of angular is ready */
if (definitelyNg1) {
if (window.angular && window.angular.resumeBootstrap) {
return callback(1);
return callback({ver: 1});
}
} else if (definitelyNg2OrNewer) {
if (true /* ng2 has no resumeBootstrap() */) {
return callback(2);
return callback({ver: 2});
}
}
/* Try again (or fail) */
if (n < 1) {
if (definitelyNg1 && window.angular) {
throw new Error('angular never provided resumeBootstrap');
callback({message: 'angular never provided resumeBootstrap'});
} else if (ng12Hybrid && !window.angular) {
callback({message: 'angular 1 never loaded' +
window.getAllAngularTestabilities ? ' (are you sure this app ' +
'uses ngUpgrade? Try un-setting ng12Hybrid)' : ''});
} else {
window.setTimeout(function() {check()}, 1000);
callback({message: 'retries looking for angular exceeded'});
}
} else {
window.setTimeout(function() {check(n - 1);}, 1000);
}
};
check(attempts);
};
check();";
";

/**
* Continue to bootstrap Angular.
Expand Down Expand Up @@ -363,4 +393,4 @@ function trySelector(selector) {

#endregion
}
}
}
5 changes: 2 additions & 3 deletions src/Protractor/Protractor-NET40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="WebDriver, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Selenium.WebDriver.3.0.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
<Reference Include="WebDriver, Version=3.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Selenium.WebDriver.3.4.0\lib\net40\WebDriver.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Protractor/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Selenium.WebDriver" version="3.0.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="3.4.0" targetFramework="net40" />
</packages>