dk4210

Experience

13,420

0 Best Reply Awards

  • Member Since 6 Months Ago
  • 119 Lessons Completed
  • 0 Favorites

6th December, 2017

dk4210 left a reply on Writing To A File With Start And End • 5 days ago

I have to get better with Regex.

dk4210 left a reply on Writing To A File With Start And End • 5 days ago

@burlresearch dude your'e awesome! It worked like a champ. Here's my final code. In hopes it will help others

    $file = $filename;
    $replace = $tcontent2;
    $replacement = "#start\n{$replace}\n#end\n";
    $contents = file_get_contents($file);
    $output = preg_replace("/#start.*#end\s+/sm", $replacement, $contents);
    file_put_contents($file,$output);

5th December, 2017

dk4210 left a reply on Writing To A File With Start And End • 6 days ago

Thanks! I will give it a try.

dk4210 left a reply on Writing To A File With Start And End • 6 days ago

Yea I need it between the two placeholders, due to there being code that should not be changed under the #end placeholder.

dk4210 started a new conversation Writing To A File With Start And End • 6 days ago

Hello guys,

This i mainly a PHP question.

I have a file that contains two comments

#start

#end

I would like to search in the file and find the #start and #end tags and replace whatever is between it with custom content.

Here's the code I have so far. This will only replace one line though, which is the #start line only. I need it to replace between the two comments.

$filename = (public_path('/../tests/Browser/mytest.txt'));

    $find = "#start";
    $replace = "whatever";
    $file = $filename;
    $contents = file_get_contents($file);
    $contents = str_replace($find,$replace,$contents);
    file_put_contents($file,$contents);

Please advise

Thanks!

5th November, 2017

dk4210 left a reply on Adding A Php Editor Within The Application • 1 month ago

I guess its sort of like TinyMCE but I want to read the contents of a .php file and modify it via the application. Basically, build test cases through my application.

dk4210 started a new conversation Adding A Php Editor Within The Application • 1 month ago

Hello Guys,

Is there a package out there that I could use to modify the contents of a php file. What I have is a dusk test file that I would like for my users to be able to modify through my application instead of via IDE. Is this possible? Not worried about any security implications due to this being an Intranet only app. Anyone have any ideas?

11th October, 2017

dk4210 left a reply on An Editor Within Laravel • 2 months ago

Anyone?

10th October, 2017

dk4210 started a new conversation An Editor Within Laravel • 2 months ago

Hello Guys,

Do you know of a package that I can open certain php files to edit within an editor via the site? It's not really a wysiwyg editor. It's basically a text editor. Is there such a thing?

Thanks, Dan

5th October, 2017

dk4210 left a reply on Send Json Data From Controller And View In Blade Templete • 2 months ago

Question here.

If I have a controller that has an if statement and based on the value from the it, how would i use Ajax to grab that value and enter it in the DOM of the view?

I know I need to create a route, just unsure how to get the value from the IF statement,

dk4210 left a reply on Send Json Data From Controller And View In Blade Templete • 2 months ago

Thanks guys!

4th October, 2017

dk4210 started a new conversation Send Json Data From Controller And View In Blade Templete • 2 months ago

I can't seem to get this to work for anything.

Here is my controller code

return response()->json(['test_result' => 'Test Failed']); 

I simply want to display the value "Test Failed" in the blade template.


<span data-id="{{ $testlist->id }}" class="finalstatus" style="display: none;">

{{ test_result }} 
         
          
</span>
 

This doesn't work. I can see that its passing the Json data in the the dev tools.

{test_result: "Test Passed"}
test_result: Test Passed"

I've tried json decode and many things with no success.

Please advise.

Thanks, Dan

29th September, 2017

dk4210 left a reply on Passing A Variable From One Method To The Other Within The Same Controller • 2 months ago

So How can I simply pass a string to my view then based on if isSuccessful() is true of false?

dk4210 left a reply on Passing A Variable From One Method To The Other Within The Same Controller • 2 months ago

Changed it to return and still no value. Baffling me

public function testresult($test_result){
            return $test_result;
        }

dk4210 left a reply on Passing A Variable From One Method To The Other Within The Same Controller • 2 months ago

Still no value returning

``

$this->testresult($test_result); //echo $process->getOutput();

}

    public function testresult($test_result){
        echo $test_result;
    }

I know the ajax call works cause I can do this

public function testresult($test_result){ echo "String to display"; }

dk4210 left a reply on Passing A Variable From One Method To The Other Within The Same Controller • 2 months ago

I'm wanting to use an ajax call to get the value so in my web.php file I have this

Route::get('gettestresult','[email protected]');

My ajax call is this

 $.get( "gettestresult", function( data ) {
            $( "#result" ).html( data );
          });

dk4210 left a reply on Passing A Variable From One Method To The Other Within The Same Controller • 2 months ago

This is the part I'm working on

// executes if test failes
        if (!$process->isSuccessful()) {
            return view('errors.testError', ['error' => $process->getOutput()]);
           $test_result = "Test Failed";
                  
          
        
        // throw new ProcessFailedException($process);
        
         //Executes if test passes 
        }elseif($process->isSuccessful()) {

           return view('success.testSuccess', ['success' => $process->getOutput()]);
           $test_result = "Test Passed";
        }else{
            echo "System error: issue with getting the test results";
        }

        testresult($test_result);
        //echo $process->getOutput();
      
       
}

        public function testresult($test_result){
            echo $test_result;
        }



}


dk4210 left a reply on Passing A Variable From One Method To The Other Within The Same Controller • 2 months ago

That didn't return the value @tykus

<?php

namespace App\Http\Controllers;


use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Session;
// use APP\testCase;



class testsController extends Controller
{

    
   
    public function index(Request $request)
    {
        $asset = $request->input('asset');
        
        $id = $request->input('id');

        // Get user id
        $userId = \Auth::user()->id;
        

        // query  with browser info to pass to Symfony process
        $testinfo = DB::table('test_display')->where('id', $id)->value('test_file_name');

         // query headless info to pass to Symfony process
         $headless = DB::table('test_display')->where('id', $id)->value('headless_file_name');

         

       // dd($headless);
        
       // Update last run
        DB::table('test_display')->where('id', $id)->update(['last_test' => \Carbon\Carbon::now()]);                       

        if($asset == "browser"){
        $commandline = "php artisan dusk tests\browser\\$testinfo";
        // insert into the test log for Browser run
        DB::table('testran_log')->insert(['user_id' => $userId,'testname' => $testinfo, 'test_type' => 'Browser', 'status' => 1, 'results' => 'sfsdffsfsdfsdfdsf' ] );
        }elseif($asset == "headless"){
        $commandline = "php artisan dusk tests\browser\\$headless"; 
        // insert into the test log for headless run
        DB::table('testran_log')->insert(['user_id' => $userId, 'testname' =>  $headless, 'test_type' => 'Headless', 'status' => 1, 'results' => 'sfsdffsfsdfsdfdsf' ] );
        }else{
            echo "System error: Command unable to complate";
        }
       
       
        $move_to_base = 'C:\xampp\htdocs\automation_team';
        $process = new \Symfony\Component\Process\Process($commandline);
        $process->setWorkingDirectory($move_to_base);
        $process->run();
        
               
        // executes if test failes
        if (!$process->isSuccessful()) {
            return view('errors.testError', ['error' => $process->getOutput()]);
           $test_result = "Test Failed";
                  
          
        
        // throw new ProcessFailedException($process);
        
         //Executes if test passes 
        }elseif($process->isSuccessful()) {

           return view('success.testSuccess', ['success' => $process->getOutput()]);
           $test_result = "Test Passed";
        }else{
            echo "System error: issue with getting the test results";
        }

        testresult($test_result);
        //echo $process->getOutput();
      
       
}

        public function testresult($test_result){
            echo $test_result;
        }



}



dk4210 left a reply on Passing A Variable From One Method To The Other Within The Same Controller • 2 months ago

Can you give me an example?

dk4210 started a new conversation Passing A Variable From One Method To The Other Within The Same Controller • 2 months ago

How would I pass a variable from one method (if statement) to another in the same controller

Like this pseudo code example


method A {

if($whatever = "Value") 
{
 $var = "A string value";

}else{

 $var = "A different string value";

}

}

method B {

echo $Var;  // This is the value from the if statement above

}

28th September, 2017

dk4210 left a reply on Passing A Variable To A Different View From The Same Controller. • 2 months ago

I don't want to return a second view I just want to pass the variable to a different view.

dk4210 left a reply on Passing A Variable To A Different View From The Same Controller. • 2 months ago

So I have to figure out a different way?

dk4210 left a reply on Passing A Variable To A Different View From The Same Controller. • 2 months ago

Ok I have the following controller called testsController and I need to pass this variable

$errorfinal = "Test Failed";

to a view other than

 return view('errors.testError', ['error' => $process->getOutput()]);

If the test failed in the if statement below I want to pass the variable to

a view called testlist.blade.php

I know I cant do this, because it will just reeload the page.

 return view('frontend.user.testlist', ['errorfinal' => $errorfinal]);

see below

dk4210 started a new conversation Passing A Variable To A Different View From The Same Controller. • 2 months ago

How can I pass a variable to a view that's not related to the controller directly.

For example

I have (controller A) that's returning a view called errors.testError and processing the result (var)

I need to have (controller A) not return a view but pass a predefined var with value to a separate view. How would I do that?

25th September, 2017

dk4210 left a reply on “unknown Command” In Laravel Dusk Tests • 2 months ago

Is this for localhost only?

dk4210 started a new conversation Dusk Steps Call Back • 2 months ago

Hello

What would be the best way to receive call backs from each step in my DUSK test case in headless mode?

Anyone have any experience with this?

20th September, 2017

dk4210 left a reply on DUSK Passing Vars To Determine Headless Or Chromedriver • 2 months ago

No one?

dk4210 left a reply on DUSK Passing Vars To Determine Headless Or Chromedriver • 2 months ago

Any one have any ideas?

19th September, 2017

dk4210 started a new conversation DUSK Passing Vars To Determine Headless Or Chromedriver • 2 months ago

Hello

I have a route that calls my controller - testController.php and in the controller I'm grabing the request variable from the querystring called asset

class testsController extends Controller
{
    public function index(Request $request)
    {
        $asset = $request->input('asset');

This in turn is calling my test case that uses a class that extends DuskTestCase

In the DuskTestCase I want to be able to grab the variable from the tesCntroller and use to determine if the test script should be headless or not.

Like this

abstract class DuskTestCase extends BaseTestCase
{
    use CreatesApplication;
  

    /**
     * Prepare for Dusk test execution.
     *
     * @beforeClass
     * @return void
     */
    public static function prepare()
    {
        $asset = 1;
        if($asset == 1){
            static::startChromeDriver();
        }
     
    }

    
    /**
     * Create the RemoteWebDriver instance.
     *
     * @return \Facebook\WebDriver\Remote\RemoteWebDriver
     */
    protected function driver()
    {
        $asset = 1;
        if($asset == 1){
         return RemoteWebDriver::create(
         'http://localhost:9515', DesiredCapabilities::chrome()
          );
        }else{
          return RemoteWebDriver::create(
          'http://localhost:4444', DesiredCapabilities::phantomjs()
            );
    
        }
    }
}

Anyone have any ideas.

15th September, 2017

dk4210 left a reply on Symfony Process - ErrorException Proc_open(): CreateProcess Failed, Error Code - 267 • 2 months ago

Both machines are windows based. Machine 1 (works) is windows 8 machine 2 is windows 10

dk4210 started a new conversation Symfony Process - ErrorException Proc_open(): CreateProcess Failed, Error Code - 267 • 2 months ago

Hello Guys,

I'm having an issue with Laravel and symfony process package. It works great on one system so I created an account on bitbucket and committed all my changes.

I then cloned the repository on a new system and manually copied over the .env file. When I run my script on the new machine i get the following error message

ErrorException
proc_open(): CreateProcess failed, error code - 267
in Process.php (line 337)

at HandleExceptions->handleError(2, 'proc_open(): CreateProcess failed, error code - 267', 'G:\\automation_team\\automation_team2\\vendor\\symfony\\process\\Process.php', 337, array('callback' => null, 'env' => null, 'descriptors' => array(array('pipe', 'r'), array('file', 'NUL', 'w'), array('file', 'NUL', 'w')), 'inheritEnv' => false, 'commandline' => 'cmd /V:ON /E:ON /D /C (php artisan dusk tests\\browser\\contentPackageTest.php) 1>"C:\\Users\\danpc\\AppData\\Local\\Temp\\sf_proc_00.out" 2>"C:\\Users\\danpc\\AppData\\Local\\Temp\\sf_proc_00.err"', 'envBackup' => array()))

at proc_open('cmd /V:ON /E:ON /D /C (php artisan dusk tests\\browser\\contentPackageTest.php) 1>"C:\\Users\\danpc\\AppData\\Local\\Temp\\sf_proc_00.out" 2>"C:\\Users\\danpc\\AppData\\Local\\Temp\\sf_proc_00.err"', array(array('pipe', 'r'), array('file', 'NUL', 'w'), array('file', 'NUL', 'w')), array(), 'C:\\xampp\\htdocs\\automation_team', null, array('suppress_errors' => true, 'bypass_shell' => true))

Anyone know why this is happening?

14th September, 2017

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 2 months ago

Update. Maybe this will help some one else. I was able to get this to work by adding the Symfony Process Component/Package

https://symfony.com/doc/current/components/process.html Works like a charm now.

8th September, 2017

7th September, 2017

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 3 months ago

Update - if I add the dd like this

$_SERVER['argv'] = []; 
    echo '<br>init Dusk...';
    Artisan::call('dusk');
    dd(Artisan::output());
    echo 'done dusk';

I get this


Warning: TTY mode is not supported on Windows platform.\r\n
Could not open input file: vendor/phpunit/phpunit/phpunit\n

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 3 months ago

So I found that I needed to remove this if statement from DuskServiceProvider.php

"if ($this->app->runningInConsole()) {"

Now when I just run this

 $_SERVER['argv'] = []; 
    echo '<br>init Dusk...';
    Artisan::call('dusk');
    echo 'done dusk';

Nothing happens. Seems as the test never runs. I'm now trying to figure out how to make it call a certain test like this

 $_SERVER['argv'] = []; 
    echo '<br>init Dusk...';
    Artisan::call('dusk:',['tests/Browser/MyTestHeadless.php']);
    echo 'done dusk';

When I run this I get this error

(1/1) CommandNotFoundException
Command "dusk:" is ambiguous.
Did you mean one of these?
dusk:install Install Dusk into the application
dusk:make Create a new Dusk test class
dusk:page Create a new Dusk page class

Every inch i get closer

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 3 months ago

Hi Mike,

If I can get it to preform the test and pass the results back and forth that would work fine, I know that selenium will work for loading the browser because I've seen it done before. I was just hoping I could get dusk to work the same way.

I just need it somehow kick off the tests via the route or controller.

Thanks!

6th September, 2017

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 3 months ago

Well how else can you build a test ui interface instead of going to the command line everytime. Can't accept that there isn't a way to accomplish this.

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 3 months ago

What ya think @MikeHopley

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 3 months ago

Hi Mike

Is there something I should add to a file to get this to work?

dk4210 left a reply on Pass Options To Dusk Via Artisan Command • 3 months ago

@leebrent you ever find an answer to this?

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 3 months ago

Here is a sample that works

Route::get('runtests', function() 
{
    echo '<br>init Dusk...';
    Artisan::call('make:controller', [ 'name' => 'myController' ]);
    echo 'done dusk';
});

This successfully creates a controller.

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 3 months ago

Actually it does. I tested that with the make:controller and it worked fine. I also noticed that dusk is listed in the artisan list but wont work from a controller or route. Seems like there is another setting somewhere that has to be updated to make this work. Surely, some one else has fired a test script from the UI.

5th September, 2017

dk4210 left a reply on Invoking The Artisan Dusk Command Outside The CLI • 3 months ago

Hi @MikeHopley

I'm still having the issue. When I add it to the web.php file and verify that the route is correct, this is what i get.


(1/1) CommandNotFoundException
Command "dusk" is not defined.
in Application.php (line 579)
at Application->find('dusk')
in Application.php (line 204)
at Application->doRun(object(ArrayInput), object(BufferedOutput))
in Application.php (line 130)
at Application->run(object(ArrayInput), object(BufferedOutput))
in Application.php (line 141)
at Application->call('dusk', array(), null)
in Kernel.php (line 220)
at Kernel->call('dusk')
in Facade.php (line 221)
at Facade::__callStatic('call', array('dusk'))
in web.php (line 17)
at Artisan::call('dusk')
in web.php (line 17)
at Router->{closure}()
in Route.php (line 190)

Any ideas.

Thanks, Dan

dk4210 left a reply on Dusk And Phantomjs Changing The User Agent • 3 months ago

Hi @yohfz that worked like a charm. Thanks!

31st August, 2017

dk4210 left a reply on Dusk And Phantomjs Changing The User Agent • 3 months ago

Anyone one?

25th August, 2017

dk4210 started a new conversation Dusk And Phantomjs Changing The User Agent • 3 months ago

Hello Guys, I'm totally confused on where to change the user agent when running the headless test.

Here is the code thats calling phantomjs. Do I add it some where in here?

return RemoteWebDriver::create(
       'http://localhost:9516', DesiredCapabilities::phantomjs()
       );

I checked out this page also http://phantomjs.org/api/webpage/property/settings.html

still not sure where or how to add the user agent.

Please advise.

24th August, 2017

dk4210 left a reply on Dusk Passing Variabels Into Test Case Steps • 3 months ago

The $pid is equal to a number.

dk4210 started a new conversation Dusk Passing Variabels Into Test Case Steps • 3 months ago

I'm trying to pass variables from a standalone page to my dusk test case, but cant seem to get it to work.

I new up'd the testVariables page

use Tests\Variables\TestVariables;

I'm trying to figure out how to pass the var $pid to my step in the test case.

->click('a[href="javascript:onedit('. $pid .');"]')

Please advise,

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.