Skip to content

Commit

Permalink
core of chrome integration done - #24
Browse files Browse the repository at this point in the history
- fix php sleep bug (now cpu usage down to 0.5% from 50%)
- save result to dom_result variable for dom step
- sendKeys - used by type / enter step
- mouse.xxx - used by hover / mouse step
- fetchText - used by read / fetch / show / print steps
- capture - used by snap step
- captureSelector - used by snap step
- download - used by download / receive steps
- evaluate - used by dom step to run in dom context
- getHTML - used by save step to get webpage html
- other CasperJS API debugHTML, reload, back, forward
- selectOptionByValue custom option selection function
- live mode of TagUI steps and supported CasperJS API

left updating tagui / tagui.cmd runners to launch PHP / Chrome
processes, and exploring frame / popup steps to set context
  • Loading branch information
kensoh committed Jul 4, 2017
1 parent a4e1689 commit ea65716
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 59 deletions.
10 changes: 5 additions & 5 deletions src/tagui_chrome.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
require('ws/Base.php'); require('ws/Client.php'); require('ws/Exception.php'); require('ws/BadOpcodeException.php');
require('ws/BadUriException.php'); require('ws/ConnectionException.php'); use WebSocket\Client; // project namespace

// delay in seconds between scanning for inputs
$scan_period = 0.050;
// delay in microseconds between scanning for inputs
$scan_period = 100000;

// counter to track current tagui chrome step
$tagui_count = '0';
Expand All @@ -35,20 +35,20 @@

// quit if finish signal received, initialise and repeat loop if blank
if ($tagui_intent == 'finish') break; else if ($tagui_intent == '')
{$tagui_count = '0'; file_put_contents('tagui_chrome.out','[0] START'); sleep($scan_period); continue;}
{$tagui_count = '0'; file_put_contents('tagui_chrome.out','[0] START'); usleep($scan_period); continue;}

// get count and repeat loop if same count as last iteration
$temp_count = trim(substr($tagui_intent,1,strpos($tagui_intent,'] ')-1));
$tagui_intent = trim(substr($tagui_intent,strpos($tagui_intent,'] ')+2));
if ($tagui_count == $temp_count) {sleep($scan_period); continue;} else $tagui_count = $temp_count;
if ($tagui_count == $temp_count) {usleep($scan_period); continue;} else $tagui_count = $temp_count;

// otherwise send input intent to chrome websocket
echo "[tagui] INPUT - \n" . "[" . $tagui_count . "] " . $tagui_intent . "\n";
$client->send($tagui_intent); $intent_result_string = trim($client->receive());

// save intent_result to interface out-file
echo "[tagui] OUTPUT - \n" . "[" . $tagui_count . "] " . $intent_result_string . "\n\n";
file_put_contents('tagui_chrome.out',"[" . $tagui_count . "] " . $intent_result_string); sleep($scan_period);}
file_put_contents('tagui_chrome.out',"[" . $tagui_count . "] " . $intent_result_string); usleep($scan_period);}

// write to interface out-file to signal finish listening
echo "[tagui] FINISH - stopped listening\n";
Expand Down
Loading

0 comments on commit ea65716

Please sign in to comment.