1

i need a script that logins to amazon on schedule. I am trying to automate it with selenium. But each time i am trying to login amazon sends a sms with password which is hard to retrive. I need to be able to this without this extra step. i decided to use separate chrome profile. but now when i run my script it freeze and i see Two-Step Verification in my console without any other error on top of this i do not see window of chrome with a blank tab. just a freeze and then this message.

Here is my code.

require_once('vendor/autoload.php');

use Applitools\RectangleSize;
use Applitools\Selenium\Eyes;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\WebDriverCapabilityType;
use Facebook\WebDriver\WebDriverBy;


$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = \Facebook\WebDriver\Remote\DesiredCapabilities::chrome();


$options = new \Facebook\WebDriver\Chrome\ChromeOptions();
$options->addArguments(array(
    '--headless',
    '--no-sandbox',
    "--disable-extensions",
    '--window-size=1920,1080',
    'user-data-dir=C:\Users\1\AppData\Local\Google\Chrome\User Data\Profile 3',
));
$options->addArguments(["start-maximized"]);
$options->setExperimentalOption("useAutomationExtension", false);
//$options->setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));

$capabilities->setCapability(\Facebook\WebDriver\Chrome\ChromeOptions::CAPABILITY, $options);

$driver = RemoteWebDriver::create($host, $capabilities,1000);
//$driver->manage()->window()->maximize();
sleep(3);
$driver->get("https://sellercentral.amazon.com/");

If i remove this line 'user-data-dir=C:\Users\1\AppData\Local\Google\Chrome\User Data\Profile 3', everything works fine except each session is unique and i have to retrive a pass they send.

How can i solve Two-Step Verification message and proceed. enter image description here

tttaaabbb
  • 407
  • 7
  • 19
  • turning off 2-step verification seems like a good plan here... or use a google voice account and automate retrieval of the SMS. – pcalkins Sep 21 '20 at 17:37
  • @pcalkins there is no google account for this profile. But i asigned one and turned 2-step verfication off. It didn't change anything – tttaaabbb Sep 21 '20 at 17:51
  • you turned off 2-step verification on the Amazon login and it still sends the SMS to login? – pcalkins Sep 21 '20 at 17:53
  • No i did it for chrome. That's the problem i'm trying to solve. If this won't work i'll turn off this for amazon. But mine problem seems to be related to access to data on my computer. – tttaaabbb Sep 21 '20 at 18:01
  • ah, ok, I thought you were entering your name/password each time. If you want to persist a login you'd need to use a profile that has already been logged in with the "remember me" option checked (manually). The session will always be new... but that's OK if "remember me" saves your login credentials. (You'll be re-logged in using the remember me cookie.) You used to be able to use different profiles and their saved cookies, but I'm not real clear on whether that's still true. – pcalkins Sep 21 '20 at 18:12

0 Answers0