Invisible intercepting element - python-3.x

I am trying to browse the chefsteps account (this one worked) and click the chefsteps account in my instagram account (the clicking part does not work). But I got "Element Click Intercepted Exception". There is no visible dialog box, but the 'chefsteps' button (element click) is intercepted. What should I do to fix this?
Traceback (most recent call last):
File "C:\Users\DELL\PycharmProjects\Day52_instagram_followers_bot\main.py", line 65, in <module>
bot.find_followers()
File "C:\Users\DELL\PycharmProjects\Day52_instagram_followers_bot\main.py", line 38, in find_followers
chefsteps.click()
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <div class="_3SOD">...</div> is not clickable at point (207, 135). Other element would receive the click: <div class="jLwSh" role="dialog"></div>
(Session info: chrome=94.0.4606.81)
import selenium.common.exceptions
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os
from time import sleep
CHROME_DRIVER_PATH ="C:\Development\chromedriver_win32\chromedriver.exe"
SIMILAR_ACCOUNT = "chefsteps"
INSTAGRAM_EMAIL = os.environ['YOUR_INSTAGRAM_EMAIL']
INSTAGRAM_PASSWORD = os.environ['YOUR_INSTAGRAM_PASSWORD']
class InstaFollower:
def __init__(self):
self.driver = webdriver.Chrome(executable_path=CHROME_DRIVER_PATH)
def login(self):
self.driver.get('https://www.instagram.com/')
sleep(3)
email = self.driver.find_element_by_name('username')
email.send_keys(INSTAGRAM_EMAIL)
password = self.driver.find_element_by_name('password')
password.send_keys(INSTAGRAM_PASSWORD)
password.send_keys(Keys.ENTER)
pass
def find_followers(self):
sleep(3)
notif = self.driver.find_element_by_xpath('/html/body/div[5]/div/div/div/div[3]/button[2]')
notif.click()
browser = self.driver.find_element_by_class_name("x3qfX")
browser.send_keys(SIMILAR_ACCOUNT)
sleep(7)
try:
chefsteps = self.driver.find_element_by_class_name('uL8Hv')
chefsteps.click()
except selenium.common.exceptions.ElementClickInterceptedException:
chefsteps = self.driver.find_element_by_css_selector('._4EzTm div')
chefsteps.click()
def follow(self):
sleep(7)
followers_button = self.driver.find_element_by_class_name('-nal3')
followers_button.click()
sleep(5)
number_of_followers = int(followers_button.get_attribute("title").replace(",", ""))
print(number_of_followers)
n = 1
while n < number_of_followers:
try:
follow_buttons = self.driver.find_elements_by_class_name("y3zKF")
for i in follow_buttons:
sleep(1)
i.click()
except selenium.common.exceptions.ElementClickInterceptedException:
cancel = self.driver.find_element_by_class_name("HoLwm")
cancel.click()
continue
bot = InstaFollower()
bot.login()
bot.find_followers()
bot.follow()

Try like below:
1: Not sure where the button appears, If the Element appears after Scrolling:
chefsteps = self.driver.find_element_by_class_name('uL8Hv')
self.driver.execute_script("arguments[0].scrollIntoView(true);",chefsteps)
chefsteps.click()
2: Can use ActionsChains:
from selenium.webdriver import ActionChains
chefsteps = self.driver.find_element_by_class_name('uL8Hv')
actions = ActionChains(self.driver)
actions.move_to_element(chefsteps).click().perform()
3: Use Javascript:
chefsteps = self.driver.find_element_by_class_name('uL8Hv')
self.driver.execute_script("arguments[0].click();",chefsteps)
If none of the above methods work, check if the Element is in an Iframe or shadow-root. And also check for the locator you are using, It should be unique in the DOM that is 1/1.

Related

How to wait for a text field to be editable with selenium in python 3.8

I am just making a selenium bot as a fun project that is supposed to play typeracer for me, and I am having a bit of trouble getting it to wait for the countdown to be done before it tries to start typing. The best way that I have found to do this is to just wait for the text input field to be editable instead of waiting for the countdown popup to be gone, but as I said before, I can't get it to wait unless I use a time.sleep() function. This wouldn't work well because of the fact that we could have to wait for anywhere from 5ish-12ish seconds before the bot can start so it could wait too long or not long enough. I have tried the solutions from many other similar questions such as this one, but so far nothing has worked.
Here is my code at the moment:
#!/usr/bin/env/python3
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class TRBot:
def __init__(self, username, passwd):
self.username = username
self.driver = webdriver.Safari()
self.driver.get("https://play.typeracer.com") # Open automated safari to typeracer
time.sleep(2)
self.driver.find_element_by_xpath("//a[#title=\"Keyboard shortcut: Ctrl+Alt+I\"]").click() # Click the "Enter a typing race" button
time.sleep(2)
inputField = WebDriverWait(self.driver, 10).until(EC.visibility_of((By.XPATH, "<div contenteditable=\"plaintext-only\"></div>")))
# Find the first word of the passage to type
text = self.driver.find_element_by_xpath("//*[#id=\"gwt - uid - 15\"]/table/tbody/tr[2]/td/table/tbody/tr[1]/td/table/tbody/tr[1]/td/div/div/span[1]").get_attribute("innerHTML")
while text != "":
inputField.send_keys(text) # Type the word
text = self.driver.find_element_by_xpath("//*[#id=\"gwt - uid - 15\"]/table/tbody/tr[2]/td/table/tbody/tr[1]/td/table/tbody/tr[1]/td/div/div/span[1]").get_attribute("innerHTML") # Find the next word
time.sleep(5)
self.driver.quit()
TypeRacerBot = TRBot("TRBot", "R0b0t#")
and here is the error output:
Traceback (most recent call last):
File "/Users/myuser/Documents/Programming/Python/TypeRacerBot.py", line 45, in <module>
TypeRacerBot = TRBot("TRBot", "R0b0t#")
File "/Users/myuser/Documents/Programming/Python/TypeRacerBot.py", line 29, in __init__
inputField = WebDriverWait(self.driver, 10).until(EC.visibility_of((By.XPATH, "<div contenteditable=\"plaintext-only\">\*</div>")))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 71, in until
value = method(self._driver)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/support/expected_conditions.py", line 144, in __call__
return _element_if_visible(self.element)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/support/expected_conditions.py", line 148, in _element_if_visible
return element if element.is_displayed() == visibility else False
AttributeError: 'tuple' object has no attribute 'is_displayed'
Right now, everything works as expected up to the inputField = WebDriverWait(... line so that's what I'm currently focused on fixing, but if you see anything that won't work further along in the code I am open to suggestions there too.
Thanks in advance!
You need to replace the line:
inputField = WebDriverWait(self.driver, 10).until(EC.visibility_of((By.XPATH, "<div contenteditable=\"plaintext-only\"></div>")))
with:
inputField = WebDriverWait(self.driver, 10).until(EC.visibility_of(self.driver.find_element_by_xpath("//div[#contenteditable='plaintext-only']")))
or:
inputField = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//div[#contenteditable='plaintext-only']")))

Python selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element

within the website https://isapps.acxiom.com/optout/optout.aspx#section8 I want to access the field “Who is opting out?”. Using the logic of the post Python Selenium webdriver: element not interactable: Element is not currently visible and may not be manipulated I tried following code
Version 1:
ele2 = driver.find_element_by_xpath("//select[#id='Identity']/option[#value='Myself']")
driver.execute_script("arguments[0].click()",ele2)
Version 2:
driver.find_element_by_xpath("//select[#id='Identity']/option[#value='Myself']").click()
The error I get is:
Traceback (most recent call last):
File "website-functions/acxiom.py", line 51, in <module>
acxiom_DD_formfill(title, firstname, middlename, lastname, suffix, email)
File "website-functions/acxiom.py", line 30, in acxiom_DD_formfill
driver.find_element_by_xpath("//select[#id='Identity']/option[#value='Myself']").click()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
'value': value})['value']
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//select[#id='Identity']/option[#value='Myself']"}
(Session info: headless chrome=80.0.3987.87)
This does not make sense to me since the id is indeed “Identity” (check at https://isapps.acxiom.com/optout/optout.aspx#section8).
Here is the full code I used:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
import os
import time
def acxiom_DD_formfill(title, firstname, middlename, lastname, suffix, email):
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=chrome_options)
driver.set_page_load_timeout(10)
driver.set_window_size(1124, 850) # set browser size.
# link to data delete form
print("opening data delete form")
driver.get("https://isapps.acxiom.com/optout/optout.aspx#section8")
#Select opt out segment: Following option values: "Mail", "Telemarketing", "Email"
ele = driver.find_element_by_xpath("//select[#id='OptOutChoices2']/option[#value='Mail']")
driver.execute_script("arguments[0].click()",ele)
print("dropdown selected")
#Select identity: Following option values: "Myself", "Legal guardian", "Deceased person"
#ele2 = driver.find_element_by_xpath("//select[#id='Identity']/option[#value='Myself']")
#driver.execute_script("arguments[0].click()",ele2)
"""Version 2"""
#driver.find_element_by_xpath("//select[#id='Identity']/option[#value='Myself']").click()
dropdown_optoutchoice=driver.find_element_by_id("'Identity'").location_once_scrolled_into_view
dropdown_optoutchoice.select_by_value('Myself')
# KEEP THIS DISABLED BC IT ACTUALLY SUBMITS
# driver.find_element_by_id("SubmitButton2").send_keys(Keys.ENTER)
print("executed")
time.sleep(4)
driver.quit()
return None
title="Mr"
middlename=""
firstname = "Joe"
lastname = "Musterman"
suffix=""
email = "joe#musterman.com"
acxiom_DD_formfill(title, firstname, middlename, lastname, suffix, email)
Thank you for your help!
Please refer below solution to select value from dropdown box. You can pass your option value and select it using drop down.
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver = webdriver.Chrome("C:\New folder\chromedriver.exe")
driver.get("https://isapps.acxiom.com/optout/optout.aspx#section8")
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//select[#id='Identity']/option[contains(text(),'Who is opting out?')]"))).click();
Here is the correct xpath.
//select[#name='Identity']/option[#value = 'Submitter']
Screenshot:
value attribute value is Submitter not Myself, which is text of the option node. That's why you are getting the error.
ele = driver.find_element_by_xpath("//select[#name='Identity']/option[#value = 'Submitter']")
driver.execute_script("arguments[0].click()",ele) # using js click so that item will be selected though it's not visible.

Appium & Python: How to move to another app?

I am making a testing bot with Python and Appium.
I need to extract the email of a button. I tired to extract href, but button are obviously something else than in smartphone applications.
So I click on this button which open my gmail with the New message window and the email in the "To" field.
SO I investigate and I could find only 1 tutoriel in Java :-(.
I found something else. SOmeone propose to instantiate new driver:
driver2 = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps2)
print("we setup driver2")
email = driver2.find_element_by_id("com.google.android.gm:id/to").text
But it stop immediately the browser. ANd Pycharm displayed this error:
Error Traceback (most recent call last): File
"C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\unittest\case.py",
line 59, in testPartExecutor
yield File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\unittest\case.py",
line 628, in run
testMethod() File "C:\Users\Nino\PycharmProjects\mybot\mybot_mybot.py", line 92, in
test_scrap_email
email = driver2.find_element_by_id("com.google.android.gm:id/to").text File
"C:\Users\Nino\PycharmProjects\mybot\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py",
line 360, in find_element_by_id
return self.find_element(by=By.ID, value=id_) File "C:\Users\Nino\PycharmProjects\mybot\venv\lib\site-packages\appium\webdriver\webdriver.py",
line 276, in find_element
'value': value})['value'] File "C:\Users\Nino\PycharmProjects\mybot\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py",
line 321, in execute
self.error_handler.check_response(response) File "C:\Users\Nino\PycharmProjects\mybot\venv\lib\site-packages\appium\webdriver\errorhandler.py",
line 29, in check_response
raise wde File "C:\Users\Nino\PycharmProjects\mybot\venv\lib\site-packages\appium\webdriver\errorhandler.py",
line 24, in check_response
super(MobileErrorHandler, self).check_response(response) File "C:\Users\Nino\PycharmProjects\mybot\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py",
line 242, in check_response
raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: An element
could not be located on the page using the given search parameters.
I am using unittest which instantiate one driver going to 1 app (where there si the email button), then I instantiate in the middle of the code a new driver.
But it bugs. And Icannot find anywhere an article or forum question about switching from 1 app to other app.
I prefer to let you te code of my bot:
from datetime import time
from time import sleep
from appium import webdriver
import unittest
from selenium.webdriver.common.by import By
class apptotest1(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName']='Android'
desired_caps['platformVersion']='6.0'
desired_caps['deviceName']='S6S5IN3G'
desired_caps['noReset']='true'
desired_caps['appPackage']='com.apptotest1'
desired_caps['appActivity']=' com.apptotest1.android/com.apptotest1.android.activity.MainTabActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
#self.driver = webdriver.Remote('http://0.0.0.0:4723/wd/hub',desired_caps)
def tearDown(self):
self.driver.quit()
def test_scrap_email(self):
search_button = self.driver.find_element(By.XPATH,"//android.widget.ImageView[#bounds='[126,800][162,836]']")
#search_button = self.driver.find_element(By.XPATH ("//android.widget.ImageView[#content-desc='Rechercher et explorer']"))
if search_button:
print("search_button was found!")
search_button.click()
else:
print("search_button was not found :-(")
search_field = self.driver.find_element_by_id('com.apptotest1.android:id/action_bar_search_edit_text')
search_field.send_keys('marketing')
users_button = self.driver.find_element_by_id('com.apptotest1.android:id/tab_button_fallback_icon')
if users_button:
print("users_button was found!")
users_button.click()
else:
print("users_button was not found :-(")
users_button2 = self.driver.find_element(By.XPATH, "//android.widget.ImageView[#bounds='[162,123][198,159]']")
if users_button2:
print("users_button2 was found!")
users_button2.click()
else:
print("users_button2 was not found :-(")
sleep(5)
profile_test = self.driver.find_elements_by_id("com.apptotest1.android:id/row_search_user_username")[1]
if profile_test:
print("profile_test was found!")
profile_test.click()
else:
print("profile_test was not found :-(")
sleep(5)
button_email = self.driver.find_element(By.XPATH,"//android.widget.TextView[#text='Adresse e-mail']")
if button_email:
print("button_email was found!")
button_text = button_email.text
print("button_text is :" + str(button_text))
button_email.click()
else:
print("button_email was not found :-(")
desired_caps2 = {}
desired_caps2['platformName'] = 'Android'
desired_caps2['platformVersion'] = '6.0'
desired_caps2['deviceName'] = 'S6S5IN3G'
desired_caps2['noReset'] = 'true'
desired_caps2['appPackage'] = 'com.google.android.gm'
desired_caps2['appActivity'] = ' com.google.android.gm.ComposeActivityGmailExternal'
driver2 = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps2)
print("we setup driver2")
email = driver2.find_element_by_id("com.google.android.gm:id/to").text
sleep(10)
if email:
print("email was found!")
print("Es eso que querias :-) =>" + str(email))
else:
print("Email was not found :-(")
sleep(5)
if __name__ == '__main__':
suite = unittest.Testloader().loadTestsFromTestCase(apptotest1)
unittest.TextTestRunner(verbosity=1).run(suite)
Does anyone can help me please?
It looks like you're looking for start_activity function
The driver.start_activity method opens arbitrary activities on a device. If the activity is not part of the application under test, it will also launch the activity's application.
driver.start_activity('com.foo.app', '.MyActivity')
This way you should be able to switch between applications within the bounds of the same webdriver instance
You might also find Launch command useful as it is cross-platform approach allowing kicking off any installed application. The command is available via SeeTest Appium Extension.
It seems like you just need switch context, you facing web in gmail, try :
driver2 = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps2)
print("we setup driver2")
driver2.switch_to.context('WEBVIEW_1')
email = driver2.find_element_by_id("com.google.android.gm:id/to").text
Or
# switch to webview
webview = driver.contexts.last
driver.switch_to.context(webview)
And please try without new initilize driver2
Please read this reference and this.

Selenium - Element not found - iframe issue

Running a selenium script to do some automated testing on servicenow
Getting an element not found error when trying to populate a field on the webpage. The login page has an iframe. But after login, the next page I dont think has an iframe. Also tried driver.switch_to.default_content() but this didnt seem to help.
I know the element is there and has that ID because ive looked at the html. Also tried populating a couple of other fields but had the same issue.
Any suggestions? Thanks.
Originally the url it tries to go to is - https://dev85222.service-now.com/incident.do, but before that the browser goes to the login page which is
https://dev85222.service-now.com/navpage.do, then after logging in, you get directed to incident.do. Once the script gets the the second url it produces the error -Element not found
I think it might be to do with switching iframes
The code -
from selenium import webdriver
import time
import unittest
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from datetime import date
from selenium.webdriver.common.action_chains import ActionChains
class IncidentCreate(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
def test_selenium(self):
#
identifier = "AUTOMATED TESTING"
module = "INCIDENT"
action = "CREATE"
job_name = ""
today = str(date.today())
driver = self.driver
base_url = "https://dev85999882.service-now.com/incident.do"
driver.get(base_url)
driver.implicitly_wait(5)
driver.switch_to.frame("gsft_main")
username = driver.find_element_by_id("user_name")
username.send_keys("username")
password = driver.find_element_by_id("user_password")
password.send_keys("password")
password.send_keys(Keys.RETURN)
identifier_inc = ("AUTOMATED TESTING - INCIDENT - %s" %today)
driver.switch_to.default_content()
time.sleep (10)
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "incident.category"))
)
except:
print("Element not found")
The error - Element not found
E
======================================================================
ERROR: test_selenium (main.IncidentCreate)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:/Users/user/Documents/Automation/FFOX_CLOUD_INC_CREATEv1.py", line 66, in test_selenium
category = driver.find_element_by_id("incident.category")
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 966, in find_element
'value': value})['value']
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id="incident.category"]
----------------------------------------------------------------------
Ran 1 test in 41.024s
switched to default content, right after clicking enter to login from the first page. This resolved the issue - driver.switch_to.default_content()

Weibo login in selenium in python?

I'm doing weibo login in selenium, but I can't handle window popup.
This is my code. What is problem?
from selenium import webdriver
username = 'your id'
password = 'your password'
driver = webdriver.Firefox()
driver.get("http://overseas.weibo.com/")
driver.implicitly_wait(10)
handles = driver.window_handles
driver.find_elements_by_link_text('登入微博')[0].click()
driver.implicitly_wait(10)
driver.switch_to_alert()
driver.find_element_by_name('memberid').send_keys(username)
driver.find_element_by_name('passwd').send_keys(password)
driver.find_elements_by_link_text('登入')[0].click()
Traceback (most recent call last):
File "D:/python34/weibo_login.py", line 35, in
driver.find_element_by_name('memberid').send_keys(username)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 362, in find_element_by_name
return self.find_element(by=By.NAME, value=name)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 744, in find_element
{'using': by, 'value': value})['value']
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"name","selector":"memberid"}
Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///C:/Users/hena/AppData/Local/Temp/tmpwk788t0k/extensions/fxdriver#googlecode.com/components/driver-component.js:10770)
at fxdriver.Timer.prototype.setTimeout/<.notify (file:///C:/Users/hena/AppData/Local/Temp/tmpwk788t0k/extensions/fxdriver#googlecode.com/components/driver-component.js:625)
Actually opened login form is inside an iframe. It's not an alert. You need to switch this particular iframe first before find element and sendKeys as below :-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
username = 'your id'
password = 'your password'
driver = webdriver.Firefox()
driver.get("http://overseas.weibo.com/")
wait = WebDriverWait(browser, 10)
link = wait.until(EC.visibility_of_element_located((By.LINK_TEXT, "登入微博")))
link.click()
frame = wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "cboxIframe")))
driver.switch_to_frame(frame)
user = wait.until(EC.visibility_of_element_located((By.ID, "memberid")))
user.send_keys(username)
passwd = wait.until(EC.visibility_of_element_located((By.ID, "passwd")))
passwd.send_keys(password)
button = wait.until(EC.visibility_of_element_located((By.ID, "login")))
button.click()
Hope it helps...:)

Resources