The following code is a segment of my program where I am trying to get followers of the screen_names given in excel file. Earlier my code was working fine, but now it gets stuck every time after loading twitter page on chrome. It does not enter username and password in browser. Please guide me on what could be wrong in the following code.
*driver = webdriver.Chrome('C:/name/sport/chromedriver')
driver.get("https://twitter.com/download?logged_out=1&lang=en")
time.sleep(6)
driver.find_element_by_xpath("//*[@id='signin-link']").click()
time.sleep(3)
pagecount=driver.find_element_by_xpath("//*[@id='signin-email']").send_keys('mygmail')
pagecount=driver.find_element_by_xpath("//*[@id='signin-password']").send_keys('mypassword')
time.sleep(3)
driver.find_element_by_xpath("//*[@id='signin-dropdown']/div[3]/form/input[1]").click()*
TypeError Traceback (most recent call last)
<ipython-input-1-d3a52c563a6e> in <module>()
18 driver.find_element_by_xpath("//*[@id='signin-link']").click()
19 time.sleep(3)
---> 20 pagecount=driver.find_element_by_xpath("//*[@id='email']").send_keys('[email protected]')
21 pagecount=driver.find_element_by_xpath("//*[@id='Password']").send_keys('@Kaminibruno05')
22 time.sleep(3)
C:\Users\khushi.tiwari\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in find_element_by_xpath(self, xpath)
256 driver.find_element_by_xpath('//div/td[1]')
257 """
--> 258 return self.find_element(by=By.XPATH, value=xpath)
259
260 def find_elements_by_xpath(self, xpath):
C:\Users\khushi.tiwari\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in find_element(self, by, value)
710 value = '[name="%s"]' % value
711 return self.execute(Command.FIND_ELEMENT,
--> 712 {'using': by, 'value': value})['value']
713
714 def find_elements(self, by=By.ID, value=None):
C:\Users\khushi.tiwari\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
199 response = self.command_executor.execute(driver_command, params)
200 if response:
--> 201 self.error_handler.check_response(response)
202 response['value'] = self._unwrap_value(
203 response.get('value', None))
C:\Users\khushi.tiwari\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
162
163 screen = None
--> 164 if 'screen' in value:
165 screen = value['screen']
166
TypeError: argument of type 'NoneType' is not iterable
I look at Login form on https://twitter.com/download?logged_out=1&lang=en
page, and I see no element with @id='signin-email'
or @id='signin-password'
. Instead I see login element as
<input type="text" class="text-input email-input js-signin-email" name="session[username_or_email]" autocomplete="username" placeholder="Phone, email or username">
and password as
<input type="password" class="text-input" name="session[password]" placeholder="Password" autocomplete="current-password">
So it means your xpath is wrong. Try
pagecount=driver.find_element_by_xpath("//input[contains(@name,'username')]").send_keys('mygmail')
pagecount=driver.find_element_by_xpath("//input[contains(@name,'password')]").send_keys('mypassword')
Also in the exception dump I believe you forgot to replace your real username/password, so you may want to change your password.