0

I'm trying to automate a log in on a website. I have the following code:

    def __init__(self):
        self.driver = webdriver.Chrome(executable_path = '/usr/bin/chromedriver')

    def parse(self, response):
        self.driver.get(response.url)
        self.driver.switch_to.frame(self.driver.find_element_by_id('J_loginIframe'))
        self.driver.find_element_by_name('fm-login-id').send_keys('iamgooglepenn')
        self.driver.find_element_by_id('fm-login-password').send_keys('mypassword')
        self.driver.find_element_by_class_name('fm-button fm-submit password-login').click()

Right now, this code successfully put in the log in information and click the login button; However, the web asks my spider to slide a bar to the right before logging me in. The HTML of the slidebar is as follows:

<span id="nc_1_n1z" class="nc_iconfont btn_slide" data-spm-anchor-id="0.0.0.i3.6a38teDwteDwKs" style="left:-2px";> ▫ </span>

Is there a way to automate this with python?

Tianhe Xie
  • 261
  • 1
  • 10
  • Please read why a [screenshot of HTML or code or error is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Consider updating the Question with formatted text based relevant HTML, code trials and error stack trace. – undetected Selenium Jul 15 '20 at 07:56
  • This page was displayed quickly by chrome driver. I'm not sure how to pause the chrome driver and get the HTML code of this page? I also cannot go to this page manually as explained in my question – Tianhe Xie Jul 15 '20 at 07:59
  • Thats because you haven't synchronized the [WebDriver](https://stackoverflow.com/questions/48079120/what-is-the-difference-between-chromedriver-and-webdriver-in-selenium/48080871#48080871) with the browser. – undetected Selenium Jul 15 '20 at 08:03
  • By synchronizing, do you mean the chromedriver will run in my usual chrome browser; instead of a new chrome browser? I read the link and don't really know how that question relates to my question – Tianhe Xie Jul 15 '20 at 08:52
  • synchronizing the WebDriver with the _browsing context_ is a concept which you haven't picked up yet from either of your answers. All I can say, raise question when you are stuck, contributors will help you out. – undetected Selenium Jul 15 '20 at 09:57

1 Answers1

1

I think this s because you've visited the website multiple times on that device. So if you login from a new device, that slider will most probably turn up. So to access the slider, delete your caches and cookies and try again (or use Incognito mode). Or when you see the slider during the test, right click and inspect.

So the next time when you run it, make sure to click the slider using an xpath

Hope this works!!

RushiSrinivas.K
  • 171
  • 2
  • 11