/// <summary> /// Convert a IPoint instance to a WebPoint instance. /// </summary> /// <param name="point">An IPoint instance.</param> /// <returns>A WebPoint instance.</returns> public static WebPoint ToWebPoint(this IPoint point) { WebPoint webPoint; webPoint = null; if (point.IsNotNull()) { webPoint = new WebPoint(); webPoint.IsMSpecified = point.M.HasValue; webPoint.IsZSpecified = point.Z.HasValue; if (point.M.HasValue) { webPoint.M = point.M.Value; } webPoint.X = point.X; webPoint.Y = point.Y; if (point.Z.HasValue) { webPoint.Z = point.Z.Value; } } return(webPoint); }
/// <summary> /// Load data into the WebGridCellSpeciesCount instance. /// </summary> /// <param name="gridCellObservationCount"> Information on species counts.</param> /// <param name="uniqueValue">A KeyValuePair with coordinate and count information</param> /// <param name="gridSpecification">The grid specification: bounding box, grid cell size, etc.</param> /// <param name="coordinateSystem"></param> public static void LoadData(this WebGridCellSpeciesCount gridCellObservationCount, KeyValuePair <string, long> uniqueValue, WebGridSpecification gridSpecification, WebCoordinateSystem coordinateSystem) { if (gridCellObservationCount != null) { // Returning int 32, no problem for gridcells. gridCellObservationCount.SpeciesObservationCount = uniqueValue.Value; gridCellObservationCount.GridCoordinateSystem = gridSpecification.GridCoordinateSystem; gridCellObservationCount.CoordinateSystem = coordinateSystem; gridCellObservationCount.Size = gridSpecification.GridCellSize; // Calculate grid points double centreCoordinateX = uniqueValue.Key.Split(':')[0].WebParseDouble(); double centreCoordinateY = uniqueValue.Key.Split(':')[1].WebParseDouble(); //TODO Create method: double halfGridSize = gridCellObservationCount.Size / 2.0; double upperCoordinateY = centreCoordinateY + halfGridSize; double upperCoordinateX = centreCoordinateX + halfGridSize; double lowerCoordinateY = centreCoordinateY - halfGridSize; double lowerCoordinateX = centreCoordinateX - halfGridSize; // Create Point and BoundingBox WebPoint centrePoint = new WebPoint(centreCoordinateX, centreCoordinateY); WebPoint pointMax = new WebPoint(upperCoordinateX, upperCoordinateY); WebPoint pointMin = new WebPoint(lowerCoordinateX, lowerCoordinateY); gridCellObservationCount.CentreCoordinate = centrePoint; gridCellObservationCount.OrginalCentreCoordinate = centrePoint; //gridCellObservationCount.GridCellBoundingBox = new WebBoundingBox() { Max = pointMax, Min = pointMin }; gridCellObservationCount.BoundingBox = new WebPolygon(); gridCellObservationCount.BoundingBox.LinearRings = new List <WebLinearRing>(); gridCellObservationCount.BoundingBox.LinearRings.Add(new WebLinearRing()); gridCellObservationCount.BoundingBox.LinearRings[0].Points = new List <WebPoint>(); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); //Create the linear ring that is the "bounding polygon". gridCellObservationCount.BoundingBox.LinearRings[0].Points[0].X = pointMin.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[0].Y = pointMin.Y; gridCellObservationCount.BoundingBox.LinearRings[0].Points[1].X = pointMin.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[1].Y = pointMax.Y; gridCellObservationCount.BoundingBox.LinearRings[0].Points[2].X = pointMax.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[2].Y = pointMax.Y; gridCellObservationCount.BoundingBox.LinearRings[0].Points[3].X = pointMax.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[3].Y = pointMin.Y; gridCellObservationCount.BoundingBox.LinearRings[0].Points[4].X = pointMin.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[4].Y = pointMin.Y; gridCellObservationCount.OrginalBoundingBox = new WebBoundingBox { Max = pointMax, Min = pointMin }; } }
/// <summary> /// Creates the centre coordinate from bounding box. /// </summary> /// <param name="boundingBox">The bounding box.</param> private static WebPoint CreateCentreCoordinateFromBoundingBox(WebBoundingBox boundingBox) { WebPoint point = new WebPoint( boundingBox.Min.X + ((boundingBox.Max.X - boundingBox.Min.X) / 2.0), boundingBox.Min.Y + ((boundingBox.Max.Y - boundingBox.Min.Y) / 2.0)); return(point); }
public async Task MouseMove(WebPoint location, CancellationToken cancellationToken = default(CancellationToken)) { var res = await _webView.DevTools.Input.DispatchMouseEvent(new ChromeDevTools.Input.DispatchMouseEventCommand { Type = MovedMouseEventType, Button = ChromeDevTools.Input.MouseButton.None, X = location.X, Y = location.Y, Modifiers = _session.StickyModifiers, ClickCount = 0 }, cancellationToken).ConfigureAwait(false); _session.MousePosition = location; }
/// <summary> /// Load data into the WebGridCellSpeciesCount instance. /// </summary> /// <param name="gridCellObservationCount"> Information on species counts.</param> /// <param name='dataReader'>An open data reader.</param> public static void LoadData(this WebGridCellSpeciesCount gridCellObservationCount, DataReader dataReader) { if (gridCellObservationCount != null && dataReader != null) { // Returning int 32, no problem for gridcells. gridCellObservationCount.SpeciesObservationCount = dataReader.GetInt32(ObservationGridCellSearchCriteriaData.SPECIES_OBSERVATION_COUNT); gridCellObservationCount.SpeciesCount = dataReader.GetInt32(ObservationGridCellSearchCriteriaData.SPECIES_COUNT); gridCellObservationCount.Size = dataReader.GetInt32(ObservationGridCellSearchCriteriaData.GRID_CELL_SIZE); // Calculate grid points double centreCoordinateX = Convert.ToDouble(dataReader.GetInt32(ObservationGridCellSearchCriteriaData.GRID_CELL_COORDINATE_X)); double centreCoordinateY = Convert.ToDouble(dataReader.GetInt32(ObservationGridCellSearchCriteriaData.GRID_CELL_COORDINATE_Y)); //TODO Create method: double halfGridSize = gridCellObservationCount.Size / 2.0; double upperCoordinateY = centreCoordinateY + halfGridSize; double upperCoordinateX = centreCoordinateX + halfGridSize; double lowerCoordinateY = centreCoordinateY - halfGridSize; double lowerCoordinateX = centreCoordinateX - halfGridSize; // Create Point and BoundingBox WebPoint centrePoint = new WebPoint(centreCoordinateX, centreCoordinateY); WebPoint pointMax = new WebPoint(upperCoordinateX, upperCoordinateY); WebPoint pointMin = new WebPoint(lowerCoordinateX, lowerCoordinateY); gridCellObservationCount.CentreCoordinate = centrePoint; gridCellObservationCount.OrginalCentreCoordinate = centrePoint; //gridCellObservationCount.GridCellBoundingBox = new WebBoundingBox() { Max = pointMax, Min = pointMin }; gridCellObservationCount.BoundingBox = new WebPolygon(); gridCellObservationCount.BoundingBox.LinearRings = new List <WebLinearRing>(); gridCellObservationCount.BoundingBox.LinearRings.Add(new WebLinearRing()); gridCellObservationCount.BoundingBox.LinearRings[0].Points = new List <WebPoint>(); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); gridCellObservationCount.BoundingBox.LinearRings[0].Points.Add(new WebPoint()); //Create the linear ring that is the "bounding polygon". gridCellObservationCount.BoundingBox.LinearRings[0].Points[0].X = pointMin.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[0].Y = pointMin.Y; gridCellObservationCount.BoundingBox.LinearRings[0].Points[1].X = pointMin.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[1].Y = pointMax.Y; gridCellObservationCount.BoundingBox.LinearRings[0].Points[2].X = pointMax.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[2].Y = pointMax.Y; gridCellObservationCount.BoundingBox.LinearRings[0].Points[3].X = pointMax.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[3].Y = pointMin.Y; gridCellObservationCount.BoundingBox.LinearRings[0].Points[4].X = pointMin.X; gridCellObservationCount.BoundingBox.LinearRings[0].Points[4].Y = pointMin.Y; gridCellObservationCount.OrginalBoundingBox = new WebBoundingBox { Max = pointMax, Min = pointMin }; } }
/// <summary> /// Test if point is located inside bounding box. /// Currently only two dimensions are handled. /// </summary> /// <param name="boundingBox">Bounding box.</param> /// <param name='point'>Point.</param> /// <returns>True if point is located inside bounding box.</returns> public static Boolean IsPointInside(this WebBoundingBox boundingBox, WebPoint point) { return(boundingBox.IsNotNull() && point.IsNotNull() && (boundingBox.Max.X >= point.X) && (boundingBox.Min.X <= point.X) && (boundingBox.Max.Y >= point.Y) && (boundingBox.Min.Y <= point.Y)); }
/// <summary> /// Test if point is located inside region. /// Currently only two dimensions are handled. /// </summary> /// <param name="regionGeography">This region geography.</param> /// <param name="context">Web service request context.</param> /// <param name="coordinateSystem">Coordinate system used in region.</param> /// <param name='point'>Point.</param> /// <returns>True if point is located inside region.</returns> public static Boolean IsPointInsideGeography(this WebRegionGeography regionGeography, WebServiceContext context, WebCoordinateSystem coordinateSystem, WebPoint point) { SqlGeography geographyMultiPolygon, geographyPoint; geographyPoint = point.GetGeography(); geographyMultiPolygon = regionGeography.GetMultiPolygonGeography(context, coordinateSystem); return(geographyMultiPolygon.STIntersects(geographyPoint).Value); }
private async void Button_Click_4(object sender, RoutedEventArgs e) { if (webDriver == null) { return; } if (int.TryParse(tbMouseX1.Text, out int x) && int.TryParse(tbMouseY1.Text, out int y)) { var clickLocation = new WebPoint(x, y); await webDriver.Mouse.Click(clickLocation); } }
public WebPoint GetLocationOnScreenOnceScrolledIntoView() { WebPoint res = null; var mRes = new ManualResetEventSlim(true); mRes.Reset(); Task.Run(async() => { res = await AsyncElement.LocationOnScreenOnceScrolledIntoView(); mRes.Set(); }); mRes.Wait(); return(res); }
public async Task MouseMove(WebPoint location, CancellationToken cancellationToken = default(CancellationToken)) { var res = await webView.DevTools.Session.Input.DispatchMouseEvent(new BaristaLabs.ChromeDevTools.Runtime.Input.DispatchMouseEventCommand { Type = ChromeDriverMouse.MovedMouseEventType, Button = ChromeDriverMouse.NoneMouseButton, X = location.X, Y = location.Y, Modifiers = session.sticky_modifiers, ClickCount = 0 }); session.mouse_position = location; }
/// <summary> /// Check if user has access right to this species observation. /// </summary> /// <param name="context">Web service request context.</param> /// <param name="authority">Check access right in this authority.</param> /// <returns>True if user has access right to this observation.</returns> private Boolean CheckAccessRights(WebServiceContext context, WebAuthority authority) { Dictionary <Int32, WebTaxon> taxa; List <WebRegionGeography> regionsGeography; WebPoint point; // Test if authority is related to species observations. if (authority.Identifier != AuthorityIdentifier.Sighting.ToString()) { return(false); } // Test if authority has enough protection level. if (authority.MaxProtectionLevel < ProtectionLevel) { return(false); } // Test if species observation is inside regions. if (authority.RegionGUIDs.IsNotEmpty()) { point = new WebPoint(CoordinateX, CoordinateY); regionsGeography = WebServiceData.RegionManager.GetRegionsGeographyByGuids(context, authority.RegionGUIDs, WebServiceData.SpeciesObservationManager.SpeciesObservationCoordinateSystem); if (!regionsGeography.IsPointInsideGeometry(context, WebServiceData.SpeciesObservationManager.SpeciesObservationCoordinateSystem, point)) { return(false); } } // Test if species observation belongs to specified taxa. if (authority.TaxonGUIDs.IsNotEmpty()) { taxa = WebServiceData.TaxonManager.GetTaxaByAuthority(context, authority); if (!taxa.ContainsKey(DyntaxaTaxonId)) { return(false); } } // Species observation has passed all tests. // User has access right to this species observation. return(true); }
public async Task ScrollElementIntoView(string elementId, WebPoint offset = null, CancellationToken cancellationToken = new CancellationToken()) { var region = await GetElementRegion(elementId, cancellationToken); //var location = await ScrollElementRegionIntoView(elementId, region, false); //if(offset != null) //{ // location = location.Offset(offset.X, offset.Y); //} //else //{ // location = location.Offset(region.Size.Width / 2, region.Size.Height / 2); //} }
/// <summary> /// Converts the coordinates found in the dicitionaryWebData to all the coordinate systems listed in the <see cref="CoordinateSystemId"/> enumeration. /// Supposed to be called from within any overridden ConvertCoordinates(Dictionary<string, WebDataField> dictionaryWebData) method /// </summary> /// <param name="dictionaryWebData"></param> /// <param name="xCoordinatefieldName"></param> /// <param name="yCoordinateFieldname"></param> /// <param name="coordinateSystemId"></param> protected void ConvertCoordinates(Dictionary <string, WebDataField> dictionaryWebData, string xCoordinatefieldName, string yCoordinateFieldname, CoordinateSystemId coordinateSystemId) { if (IsCurrentRecord(dictionaryWebData) || !dictionaryWebData.ContainsKey(xCoordinatefieldName) || !dictionaryWebData[xCoordinatefieldName].Value.IsDouble() || !dictionaryWebData.ContainsKey(yCoordinateFieldname) || !dictionaryWebData[yCoordinateFieldname].Value.IsDouble()) { return; } var webpoint = new WebPoint(dictionaryWebData[xCoordinatefieldName].Value.WebParseDouble(), dictionaryWebData[yCoordinateFieldname].Value.WebParseDouble()); ConvertCoordinates(webpoint, coordinateSystemId); }
public async Task SetPosition(WebPoint pos, CancellationToken cancellationToken = default(CancellationToken)) { await asyncFirefoxDriver.CheckConnected(cancellationToken).ConfigureAwait(false); if (asyncFirefoxDriver.ClientMarionette == null) { throw new Exception("error: no clientMarionette"); } var comm1 = new SetWindowPositionCommand(pos.X, pos.Y); await asyncFirefoxDriver.ClientMarionette.SendRequestAsync(comm1, cancellationToken).ConfigureAwait(false); if (comm1.Error != null) { throw new WebBrowserException(comm1.Error); } }
public async Task <string> ClickElement(string elementId) { if (_asyncChromeDriver != null) { await _asyncChromeDriver.CheckConnected().ConfigureAwait(false); } var tagName = await _elementUtils.GetElementTagName(elementId).ConfigureAwait(false); if (tagName == "option") { bool isToggleable = await _elementUtils.IsOptionElementTogglable(elementId).ConfigureAwait(false); if (isToggleable) { await _elementUtils.ToggleOptionElement(elementId).ConfigureAwait(false); return("ToggleOptionElement"); } else { await _elementUtils.SetOptionElementSelected(elementId).ConfigureAwait(false); return("SetOptionElementSelected"); } } else { WebPoint location = await _elementUtils.GetElementClickableLocation(elementId).ConfigureAwait(false); await _webView.DevTools.Input.DispatchMouseEvent(new ChromeDevTools.Input.DispatchMouseEventCommand { Type = ChromeDriverMouse.MovedMouseEventType, Button = ChromeDevTools.Input.MouseButton.None, X = location.X, Y = location.Y, Modifiers = Session.StickyModifiers, ClickCount = 0 }).ConfigureAwait(false); await _webView.DevTools.Input.DispatchMouseEvent(new ChromeDevTools.Input.DispatchMouseEventCommand { Type = ChromeDriverMouse.PressedMouseEventType, Button = ChromeDevTools.Input.MouseButton.Left, X = location.X, Y = location.Y, Modifiers = Session.StickyModifiers, ClickCount = 1 }).ConfigureAwait(false); await _webView.DevTools.Input.DispatchMouseEvent(new ChromeDevTools.Input.DispatchMouseEventCommand { Type = ChromeDriverMouse.ReleasedMouseEventType, Button = ChromeDevTools.Input.MouseButton.Left, X = location.X, Y = location.Y, Modifiers = Session.StickyModifiers, ClickCount = 1 }).ConfigureAwait(false); Session.MousePosition = location; //await new ChromeDriverMouse(webView).Click(location); return("Click"); } }
public void GetGeometryNoZValueError() { SqlGeometry geometryPoint; WebPoint point; point = new WebPoint(); point.X = 1000; point.Y = 2000; point.IsZSpecified = false; point.IsMSpecified = true; point.M = 4000; geometryPoint = point.GetGeometry(); Assert.IsNotNull(geometryPoint); Assert.AreEqual(SqlGeometryType.Point, geometryPoint.GetGeometryType()); Assert.AreEqual(point.X, geometryPoint.STX); Assert.AreEqual(point.Y, geometryPoint.STY); Assert.AreEqual(point.M, (Double)geometryPoint.M); }
public async Task Click(WebPoint location, CancellationToken cancellationToken = default(CancellationToken)) { if (_session.MousePosition != location) { await _webView.DevTools.Input.DispatchMouseEvent(new ChromeDevTools.Input.DispatchMouseEventCommand { Type = MovedMouseEventType, Button = NoneMouseButton, X = location.X, Y = location.Y, Modifiers = _session.StickyModifiers, ClickCount = 0 }, cancellationToken).ConfigureAwait(false); } await _webView.DevTools.Input.DispatchMouseEvent(new ChromeDevTools.Input.DispatchMouseEventCommand { Type = PressedMouseEventType, Button = LeftMouseButton, X = location.X, Y = location.Y, Modifiers = _session.StickyModifiers, ClickCount = 1 }, cancellationToken).ConfigureAwait(false); await _webView.DevTools.Input.DispatchMouseEvent(new ChromeDevTools.Input.DispatchMouseEventCommand { Type = ReleasedMouseEventType, Button = LeftMouseButton, X = location.X, Y = location.Y, Modifiers = _session.StickyModifiers, ClickCount = 1 }, cancellationToken).ConfigureAwait(false); _session.MousePosition = location; }
/// <summary> /// Test if point is located inside any of the regions. /// Currently only two dimensions are handled. /// </summary> /// <param name="regionsGeography">Regions geography.</param> /// <param name="context">Web service request context.</param> /// <param name="coordinateSystem">Coordinate system used in region.</param> /// <param name='point'>Point.</param> /// <returns>True if point is located inside at least one of the regions.</returns> public static Boolean IsPointInsideGeometry(this List <WebRegionGeography> regionsGeography, WebServiceContext context, WebCoordinateSystem coordinateSystem, WebPoint point) { if (regionsGeography.IsNotEmpty()) { foreach (WebRegionGeography regionGeography in regionsGeography) { if (regionGeography.IsPointInsideGeometry(context, coordinateSystem, point)) { // Species observation is inside one of the regions. return(true); } } } // Species observation is not inside any of the regions. return(false); }
/// <summary> /// Test if point is located inside region. /// Currently only two dimensions are handled. /// </summary> /// <param name="regionGeography">This region geography.</param> /// <param name="context">Web service request context.</param> /// <param name="coordinateSystem">Coordinate system used in region.</param> /// <param name='point'>Point.</param> /// <returns>True if point is located inside region.</returns> public static Boolean IsPointInsideGeometry(this WebRegionGeography regionGeography, WebServiceContext context, WebCoordinateSystem coordinateSystem, WebPoint point) { SqlGeometry geometryMultiPolygon, geometryPoint; if (regionGeography.BoundingBox.IsPointInside(point)) { geometryPoint = point.GetGeometry(); geometryMultiPolygon = regionGeography.GetMultiPolygonGeometry(context, coordinateSystem); return(geometryMultiPolygon.STContains(geometryPoint).Value); } else { // Species observation can not be inside region // since it is not inside the regions bounding box. return(false); } }
public async Task ShouldBeAbleToGetTheLocationOfAnElement() { await driver.GoToUrl(javascriptPage); if (!(driver is IJavaScriptExecutor)) { return; } await((IJavaScriptExecutor)driver).ExecuteScript("window.focus();"); IWebElement element = await driver.FindElement(By.Id("keyUp")); if (!(element is ILocatable)) { return; } WebPoint point = await((ILocatable)element).LocationOnScreenOnceScrolledIntoView(); Assert.That(point.X, Is.GreaterThan(1)); Assert.That(point.Y, Is.GreaterThanOrEqualTo(0)); }
/// <summary> /// Convert a IPoint instance to a WebPoint instance. /// </summary> /// <param name="point">An IPoint instance.</param> /// <returns>A WebPoint instance.</returns> protected WebPoint GetPoint(IPoint point) { WebPoint webPoint; webPoint = null; if (point.IsNotNull()) { webPoint = new WebPoint(); webPoint.IsMSpecified = point.M.HasValue; webPoint.IsZSpecified = point.Z.HasValue; if (point.M.HasValue) { webPoint.M = point.M.Value; } webPoint.X = point.X; webPoint.Y = point.Y; if (point.Z.HasValue) { webPoint.Z = point.Z.Value; } } return(webPoint); }
public async Task DoubleClick(WebPoint location, CancellationToken cancellationToken = default(CancellationToken)) { await Click(location, cancellationToken); await Click(location, cancellationToken); }
public async Task DoubleClick(WebPoint location, CancellationToken cancellationToken = default(CancellationToken)) { await Click(location, cancellationToken).ConfigureAwait(false); await Click(location, cancellationToken).ConfigureAwait(false); }
public async Task <string> ClickElement(string elementId) { await asyncChromeDriver.CheckConnected(); var tag_name = await elementUtils.GetElementTagName(elementId); if (tag_name == "option") { bool is_toggleable = await elementUtils.IsOptionElementTogglable(elementId); if (is_toggleable) { await elementUtils.ToggleOptionElement(elementId); return("ToggleOptionElement"); } else { await elementUtils.SetOptionElementSelected(elementId); return("SetOptionElementSelected"); } } else { WebPoint location = await elementUtils.GetElementClickableLocation(elementId); var res = await webView.DevTools.Session.Input.DispatchMouseEvent(new BaristaLabs.ChromeDevTools.Runtime.Input.DispatchMouseEventCommand { Type = ChromeDriverMouse.MovedMouseEventType, Button = ChromeDriverMouse.NoneMouseButton, X = location.X, Y = location.Y, Modifiers = Session.sticky_modifiers, ClickCount = 0 }); res = await webView.DevTools.Session.Input.DispatchMouseEvent(new BaristaLabs.ChromeDevTools.Runtime.Input.DispatchMouseEventCommand { Type = ChromeDriverMouse.PressedMouseEventType, Button = ChromeDriverMouse.LeftMouseButton, X = location.X, Y = location.Y, Modifiers = Session.sticky_modifiers, ClickCount = 1 }); res = await webView.DevTools.Session.Input.DispatchMouseEvent(new BaristaLabs.ChromeDevTools.Runtime.Input.DispatchMouseEventCommand { Type = ChromeDriverMouse.ReleasedMouseEventType, Button = ChromeDriverMouse.LeftMouseButton, X = location.X, Y = location.Y, Modifiers = Session.sticky_modifiers, ClickCount = 1 }); Session.mouse_position = location; //await new ChromeDriverMouse(webView).Click(location); return("Click"); } }
public async Task MouseMove(WebPoint location, CancellationToken cancellationToken = default(CancellationToken)) { await asyncFirefoxDriver.CheckConnected(cancellationToken).ConfigureAwait(false); throw new NotImplementedException(); }
public Task MouseUp(WebPoint location, CancellationToken cancellationToken = default(CancellationToken)) { throw new NotImplementedException(); }
public override string GetInfo() { return(ElementName + ", " + WebPoint.GetInfo() + ", " + WebHight + ", " + WebWidth + ", " + Select); }
public async Task PerformActions(IList <ActionSequence> actionSequenceList, CancellationToken cancellationToken = default(CancellationToken)) { _performActionsCancellationTokenSource = new CancellationTokenSource(); using (CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(_performActionsCancellationTokenSource.Token, cancellationToken)) { try { var ct = linkedCts.Token; ct.ThrowIfCancellationRequested(); foreach (var action in actionSequenceList) { ct.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested(); foreach (var interaction in action.Interactions) { //await Task.Delay(100); if (interaction is PauseInteraction) { await Task.Delay(((PauseInteraction)interaction).Duration, ct).ConfigureAwait(false); } else if (interaction is PointerInputDevice.PointerDownInteraction) { var pdi = (PointerInputDevice.PointerDownInteraction)interaction; var pk = ((PointerInputDevice)interaction.SourceDevice).PointerKind; if (pk == PointerKind.Mouse) { if (pdi.Button == MouseButton.Left) { await _asyncChromeDriver.Mouse.MouseDown(_asyncChromeDriver.Session.MousePosition, ct).ConfigureAwait(false); } else if (pdi.Button == MouseButton.Right) { await _asyncChromeDriver.Mouse.ContextClick(_asyncChromeDriver.Session.MousePosition, ct).ConfigureAwait(false); } } else if (pk == PointerKind.Touch) { if (pdi.Button == MouseButton.Left) { await _asyncChromeDriver.TouchScreen.Down(_asyncChromeDriver.Session.MousePosition.X, _asyncChromeDriver.Session.MousePosition.Y, ct).ConfigureAwait(false); } else if (pdi.Button == MouseButton.Right) { throw new NotSupportedException("Touch with MouseButton.Right"); } } else if (pk == PointerKind.Pen) { throw new NotImplementedException("PointerKind.Pen"); } } else if (interaction is PointerInputDevice.PointerUpInteraction) { var pui = (PointerInputDevice.PointerUpInteraction)interaction; var pk = ((PointerInputDevice)interaction.SourceDevice).PointerKind; if (pk == PointerKind.Mouse) { if (pui.Button == MouseButton.Left) { await _asyncChromeDriver.Mouse.MouseUp(_asyncChromeDriver.Session.MousePosition, ct).ConfigureAwait(false); } else if (pui.Button == MouseButton.Right) { await _asyncChromeDriver.Mouse.ContextClick(_asyncChromeDriver.Session.MousePosition, ct).ConfigureAwait(false); } } else if (pk == PointerKind.Touch) { throw new NotSupportedException("Touch with MouseButton.Right"); } else if (pk == PointerKind.Pen) { throw new NotImplementedException("PointerKind.Pen"); } } else if (interaction is PointerInputDevice.PointerCancelInteraction) { } else if (interaction is PointerInputDevice.PointerMoveInteraction) { var pmi = (PointerInputDevice.PointerMoveInteraction)interaction; var pk = ((PointerInputDevice)interaction.SourceDevice).PointerKind; if (pk == PointerKind.Mouse) { if (pmi.Target != null) { if (pmi.X != 0 || pmi.Y != 0) { WebPoint location = await pmi.Target.Location().ConfigureAwait(false); location = location.Offset(pmi.X, pmi.Y); await _asyncChromeDriver.Mouse.MouseMove(location, ct).ConfigureAwait(false); } else { //WebPoint location = await asyncChromeDriver.ElementUtils.GetElementClickableLocation(pmi.Target.Id, ct); //if (location == null) var location = await _asyncChromeDriver.Elements.GetElementLocation(pmi.Target.Id, ct).ConfigureAwait(false); await _asyncChromeDriver.Mouse.MouseMove(location, ct).ConfigureAwait(false); } } else { await _asyncChromeDriver.Mouse.MouseMove(_asyncChromeDriver.Session.MousePosition.Offset(pmi.X, pmi.Y), ct).ConfigureAwait(false); } } else if (pk == PointerKind.Touch) { if (pmi.Target != null) { if (pmi.X != 0 || pmi.Y != 0) { WebPoint location = await pmi.Target.Location().ConfigureAwait(false); location = location.Offset(pmi.X, pmi.Y); await _asyncChromeDriver.TouchScreen.Move(location.X, location.Y, ct).ConfigureAwait(false); } else { //WebPoint location = await asyncChromeDriver.ElementUtils.GetElementClickableLocation(pmi.Target.Id); var location = await _asyncChromeDriver.Elements.GetElementLocation(pmi.Target.Id, ct).ConfigureAwait(false); if (location != null) { await _asyncChromeDriver.TouchScreen.Move(location.X, location.Y, ct).ConfigureAwait(false); } } } else { var newLoc = _asyncChromeDriver.Session.MousePosition.Offset(pmi.X, pmi.Y); await _asyncChromeDriver.TouchScreen.Move(newLoc.X, newLoc.Y, ct).ConfigureAwait(false); } } else if (pk == PointerKind.Pen) { throw new NotImplementedException("PointerKind.Pen"); } } else if (interaction is KeyInputDevice.KeyDownInteraction) { var value = ((KeyInputDevice.KeyDownInteraction)interaction).GetValue(); await _asyncChromeDriver.Keyboard.PressKey(value, ct).ConfigureAwait(false); } else if (interaction is KeyInputDevice.KeyUpInteraction) { var value = ((KeyInputDevice.KeyUpInteraction)interaction).GetValue(); await _asyncChromeDriver.Keyboard.ReleaseKey(value, ct).ConfigureAwait(false); } } } } catch { throw; } } }
public async Task <bool> VerifyElementClickable(string elementId, WebPoint location, CancellationToken cancellationToken = new CancellationToken()) { var res = await webView.CallFunction(atoms.IS_ELEMENT_CLICKABLE, $"{{\"{GetElementKey()}\":\"{elementId}\"}}, {location.X}, {location.Y}", null, true, false, cancellationToken); return(ResultValueConverter.ToBool(res?.Result?.Value)); }
/// <summary> /// Creates a SQL geometry grid based on a grid specification. /// </summary> /// <param name="gridSpecification">The grid specification.</param> /// <param name="srid">The srid that is used.</param> /// <param name="centrePointList">The centre point list.</param> public static List <SqlGeometry> CreateSqlGeometryGrid(WebGridSpecification gridSpecification, int srid, out List <WebPoint> centrePointList) { SqlGeometry newCell; WebPoint centrePoint; SqlGeometryBuilder geomBuilder; List <SqlGeometry> gridCellList = null; Double xMin, yMin, xMax, yMax; Int32 cellSize; centrePointList = new List <WebPoint>(); if (gridSpecification.IsNotNull() && centrePointList.IsNotNull() && gridSpecification.GridCellSize.IsNotNull()) { cellSize = gridSpecification.GridCellSize; // Adjust grid into even integer intervals. // this means that the first grid cells may exceed the boundary box. xMin = Math.Floor(gridSpecification.BoundingBox.Min.X / cellSize) * cellSize; xMax = Math.Ceiling(gridSpecification.BoundingBox.Max.X / cellSize) * cellSize; yMin = Math.Floor(gridSpecification.BoundingBox.Min.Y / cellSize) * cellSize; yMax = Math.Ceiling(gridSpecification.BoundingBox.Max.Y / cellSize) * cellSize; //Todo: This should be done in earlier checkdata if (xMin >= xMax) { throw new Exception(string.Format("The bounding box is defect. xMin={0}, xMax={1}", xMin, xMax)); } if (yMin >= yMax) { throw new Exception(string.Format("The bounding box is defect.yMin={0}, yMax={1}", yMin, yMax)); } double count = ((xMax - xMin) / cellSize) * ((yMax - yMin) / cellSize); if (count > 200000) { throw new Exception("Too many grid cells. Use larger cell size or smaller bounding box."); } //Create a gridcell polygon list and a corresponding centre point list gridCellList = new List <SqlGeometry>(); while (xMin < xMax) //The last grid cell may exceed the boundary box { while (yMin < yMax) //The last grid cell may exceed the boundary box { //Build new list of cells geomBuilder = new SqlGeometryBuilder(); geomBuilder.SetSrid(srid); geomBuilder.BeginGeometry(OpenGisGeometryType.Polygon); geomBuilder.BeginFigure(xMin, yMin); geomBuilder.AddLine(xMin + cellSize, yMin); geomBuilder.AddLine(xMin + cellSize, yMin + cellSize); geomBuilder.AddLine(xMin, yMin + cellSize); geomBuilder.AddLine(xMin, yMin); geomBuilder.EndFigure(); geomBuilder.EndGeometry(); newCell = geomBuilder.ConstructedGeometry; gridCellList.Add(newCell); //Create a list of centre points centrePoint = new WebPoint(); centrePoint.X = Math.Floor(xMin / cellSize) * cellSize + cellSize * 0.5; centrePoint.Y = Math.Floor(yMin / cellSize) * cellSize + cellSize * 0.5; if (centrePointList.IsNotNull()) { centrePointList.Add(centrePoint); } yMin = yMin + cellSize; } xMin = xMin + cellSize; yMin = Math.Floor(gridSpecification.BoundingBox.Min.Y / cellSize) * cellSize; } } return(gridCellList); }