text stringlengths 0 234 |
|---|
function Headless return League.JSON.Values.JSON_Value is |
Cap : League.JSON.Objects.JSON_Object; |
Options : League.JSON.Objects.JSON_Object; |
Args : League.JSON.Arrays.JSON_Array; |
begin |
return Cap.To_JSON_Value; |
pragma Warnings (Off); |
Args.Append (League.JSON.Values.To_JSON_Value (+"--headless")); |
Args.Append (League.JSON.Values.To_JSON_Value (+"--disable-extensions")); |
Args.Append (League.JSON.Values.To_JSON_Value (+"--no-sandbox")); |
Options.Insert (+"args", Args.To_JSON_Value); |
Options.Insert |
(+"binary", |
League.JSON.Values.To_JSON_Value |
(+"/usr/lib64/chromium-browser/headless_shell")); |
Cap.Insert (+"chromeOptions", Options.To_JSON_Value); |
return Cap.To_JSON_Value; |
end Headless; |
Web_Driver : aliased WebDriver.Drivers.Driver'Class |
:= WebDriver.Remote.Create (+"http://127.0.0.1:9515"); |
Session : constant WebDriver.Sessions.Session_Access := |
Web_Driver.New_Session (Headless); |
begin |
Session.Go (+"http://www.ada-ru.org/"); |
Ada.Wide_Wide_Text_IO.Put_Line |
(Session.Get_Current_URL.To_Wide_Wide_String); |
declare |
Body_Element : constant WebDriver.Elements.Element_Access := |
Session.Find_Element |
(Strategy => WebDriver.Tag_Name, |
Selector => +"body"); |
begin |
Ada.Wide_Wide_Text_IO.Put_Line |
("Selected=" & Boolean'Wide_Wide_Image (Body_Element.Is_Selected)); |
Ada.Wide_Wide_Text_IO.Put_Line |
("itemtype=" & |
Body_Element.Get_Attribute (+"itemtype").To_Wide_Wide_String); |
Ada.Wide_Wide_Text_IO.Put_Line |
("height=" & |
Body_Element.Get_CSS_Value (+"height").To_Wide_Wide_String); |
Ada.Wide_Wide_Text_IO.Put_Line |
("tag=" & Body_Element.Get_Tag_Name.To_Wide_Wide_String); |
Function Definition: procedure Example is |
Function Body: Addr : constant League.Strings.Universal_String := |
League.Application.Arguments.Element (1); |
Error : League.Strings.Universal_String; |
Manager : Network.Managers.Manager; |
Promise : Network.Connection_Promises.Promise; |
begin |
Manager.Initialize; |
Network.Managers.TCP_V4.Register (Manager); |
Manager.Connect |
(Address => Network.Addresses.To_Address (Addr), |
Error => Error, |
Promise => Promise); |
if not Error.Is_Empty then |
Ada.Wide_Wide_Text_IO.Put_Line |
("Connect fails: " & Error.To_Wide_Wide_String); |
return; |
end if; |
declare |
Listener : aliased Listeners.Listener := |
(Promise => Promise, others => <>); |
begin |
Promise.Add_Listener (Listener'Unchecked_Access); |
for J in 1 .. 100 loop |
Manager.Wait (1.0); |
exit when Listener.Done; |
end loop; |
Function Definition: procedure Free is new Ada.Unchecked_Deallocation |
Function Body: (List_Node, List_Node_Access); |
function Has_Listener |
(Self : Promise'Class; |
Value : not null Listener_Access) return Boolean; |
------------------ |
-- Add_Listener -- |
------------------ |
not overriding procedure Add_Listener |
(Self : in out Promise'Class; |
Value : not null Listener_Access) |
is |
Parent : constant Controller_Access := Self.Parent; |
begin |
case Parent.Data.State is |
when Pending => |
if not Self.Has_Listener (Value) then |
Parent.Data.Listeners := new List_Node' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.