0

Newbie to automation with Selenium/Python. I'm getting blocked automating a sign up form. The drop down is a required element but I'm getting the following error...

AttributeError: 'list' object has no attribute 'tag_name'

I've posted my code below and can't find any answer online as to why this would be. Any/all help greatly appreciated.

from re import X
from socket import timeout
from selenium import webdriver

from selenium.webdriver.support.ui import Select
from locale import currency
from operator import index
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

from unicodedata import name
import pandas as pd
import csv
import time
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait 
web = webdriver.Chrome("/home/nosra/chromedriver")
#class selenium :webdriver.support.wait.WebDriverWait(web, timeout, poll_frequency=0.5, ignored_exceptions=None)


df=pd.read_excel('info1.xlsx')
url=["https://docs.google.com/forms/d/e/1FAIpQLScGMoYVsxtsQ0Je4RTYEZndWrKkdt5jJwXBcMAcOia2WuIRtA/viewform?usp=sf_link"]
for link in url:  
    for i in df.index :
     web.get(link)
     entry=df.loc[i]     
     name=web.find_element(By.XPATH,"//*[@id='mG61Hd']/div[2]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[1]/input")
     time.sleep(1)
     name.send_keys(entry['name'])
     time.sleep(1)
     lastName=web.find_element(By.XPATH,"//*[@id='mG61Hd']/div[2]/div/div[2]/div[2]/div/div/div[2]/div/div[1]/div/div[1]/input")
     time.sleep(2)
     lastName.send_keys(entry['lastName '])
    
select_C=Select(web.find_elements(By.XPATH,"//*[@id='mG61Hd']/div[2]/div/div[2]/div[3]/div/div/div[2]/div/div[1]/div[1]/div[3]/span"))
select_C.select_by_index(1)```
       
1
  • 1
    At which line are you getting the error exactly? Commented Jul 18, 2022 at 11:25

1 Answer 1

-1

select_C defined wrong: you should pass single WebElement to Select (so you need to use web.find_element instead of web.find_elements) and also your XPath should fetch select node not span. Select class is not applicable here. Just click on

web.find_element('xpath', '//div[@role="option"]').click()

to open drop-down menu and then

web.find_element('xpath', '//div[@data-value="Tunisia" and @aria-selected="false"]').click()

to select option

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.