1

This is my first question in OS and I would describe it in details with my best effort.

Selenium3.0.2

firefox 45.6.0

geckodriver 0.13.0

python 3.5.1 (with Anaconda 2.4.1 (64bit))

What I want to do is to automate the process of registering a new facebook account. The below code can set values in boxes such as "first name" and "password".

However, it cannot make any selection from the drop down list, such "day", "month", or "year"

# -*- coding: utf-8 -*-
import selenium
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from datetime import datetime
import unittest, time, re
browser = webdriver.Firefox()
browser.get('https://www.facebook.com')
browser.maximize_window()
browser.find_element_by_id("u_0_1").send_keys("firstName")
time.sleep(2)
browser.find_element_by_id("u_0_3").send_keys("lastName")
time.sleep(2)
browser.find_element_by_id("u_0_5").send_keys("[email protected]")
time.sleep(2)
browser.find_element_by_id("u_0_8").send_keys("[email protected]")
time.sleep(2)
browser.find_element_by_id("u_0_a").send_keys("testpassword")
time.sleep(2)
Select(browser.find_element_by_id("month")).select_by_visible_text("Jan")
time.sleep(2)
Select(browser.find_element_by_id("month")).select_by_visible_text("Feb")
time.sleep(2)
Select(browser.find_element_by_id("month")).select_by_visible_text("Apr")
time.sleep(2)
Select(browser.find_element_by_id("month")).select_by_visible_text("Dec")
time.sleep(2)
Select(browser.find_element_by_id("day")).select_by_visible_text("1")
time.sleep(2)
Select(browser.find_element_by_id("day")).select_by_visible_text("7")
time.sleep(2)
Select(browser.find_element_by_id("day")).select_by_visible_text("11")
time.sleep(2)
Select(browser.find_element_by_id("day")).select_by_visible_text("28")
time.sleep(2)
Select(browser.find_element_by_id("year")).select_by_visible_text("1990")
time.sleep(2)
Select(browser.find_element_by_id("year")).select_by_visible_text("1991")
time.sleep(2)
Select(browser.find_element_by_id("year")).select_by_visible_text("1992")
time.sleep(2)
Select(browser.find_element_by_id("year")).select_by_visible_text("1993")
time.sleep(2)
#select gender
browser.find_element_by_id("u_0_i").click()
asked Jan 11, 2017 at 17:49
3
  • Try seperating this line of code into two, Select(browser.find_element_by_id("month")).select_by_visible_text("Jan"); first click on the month button, wait for half a second then click on an item on its dropdown list. Commented Jan 11, 2017 at 19:54
  • @YuZhang Thanks! I tried this but still not working. Turns out using selenium2 works well on this. Commented Jan 11, 2017 at 21:56
  • all good, glad it worked out for you. Commented Jan 11, 2017 at 22:05

1 Answer 1

1

The above code works well with the following setup:

Python3.5.2 (anaconda3 4.2.0)

Firefox 45.6.0

selenium 2.53.1

I think either selenium3 or the gechodriver has bug on this.

answered Jan 11, 2017 at 21:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.