Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-mw committed Apr 22, 2022
1 parent 87bc104 commit ce27008
Showing 1 changed file with 60 additions and 55 deletions.
115 changes: 60 additions & 55 deletions src/tests/Browser/Components/ShopmagShopProductLinksScraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,62 @@
use Laravel\Dusk\Component as BaseComponent;
use MicroweberPackages\Page\Models\Page;

class ShopmagShopProductLinksScraper extends BaseComponent
{
/**
* Get the root selector for the component.
*
* @return string
*/
public function selector()
{
return '.main';
}

/**
* Assert that the browser page contains the component.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
// $browser->assertVisible($this->selector());
}
if (!class_exists('\MicroweberPackages\Template\Shopmag\tests\Browser\Components\ShopmagShopProductLinksScraper')) {

/**
* Get the element shortcuts for the component.
*
* @return array
*/
public function elements()
class ShopmagShopProductLinksScraper extends BaseComponent
{
return [];
}

public $productLinks;
public function scrapLinks(Browser $browser)
{
$findHome = Page::where('is_home', 1)->first();

$browser->visit($findHome->link());

$browser->waitForText('Shop',30);

$shopLink = $browser->script("return $('#header_menu').find('a:contains(\"Shop\")').first().attr('href')");
$browser->visit($shopLink[0]);

$browser->pause(3000);

$browser->waitForText('Shop');
$browser->pause(3000);

$currencySymbol = get_currency_symbol();

$this->productLinks = $browser->script("
/**
* Get the root selector for the component.
*
* @return string
*/
public function selector()
{
return '.main';
}

/**
* Assert that the browser page contains the component.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
// $browser->assertVisible($this->selector());
}

/**
* Get the element shortcuts for the component.
*
* @return array
*/
public function elements()
{
return [];
}

public $productLinks;

public function scrapLinks(Browser $browser)
{
$findHome = Page::where('is_home', 1)->first();

$browser->visit($findHome->link());

$browser->waitForText('Shop', 30);

$shopLink = $browser->script("return $('#header_menu').find('a:contains(\"Shop\")').first().attr('href')");
$browser->visit($shopLink[0]);

$browser->pause(3000);

$browser->waitForText('Shop');
$browser->pause(3000);

$currencySymbol = get_currency_symbol();

$this->productLinks = $browser->script("
var links = [];
$('.module-shop .col-xl-4').each(function(index) {
Expand All @@ -78,10 +81,12 @@ public function scrapLinks(Browser $browser)
return links;
")[0];

}
}

public function getLinks()
{
return $this->productLinks;
public function getLinks()
{
return $this->productLinks;
}
}

}

0 comments on commit ce27008

Please sign in to comment.