AttributeError: 'list' object has no attribute 'click' - Selenium Webdriver
I am trying to use click command in Selenium webdriver using python. But I am getting the below error. Can some one help me?
Traceback (most recent call last):
File "C:UsersvikramworkspaceLDCtest.py", line 13, in <module>
driver.find_elements_by_link_text("MISCQA Misc Tests").click()
AttributeError: 'list' object has no attribute 'click'
Here is my program
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
import config
url = config.config.get('url')
driver = webdriver.Ie()
driver.get(url)
driver.find_elements_by_link_text("MISCQA Misc Tests").click()
driver.close()
I think I am missing some thing. Please suggest me
python selenium webdriver
add a comment |
I am trying to use click command in Selenium webdriver using python. But I am getting the below error. Can some one help me?
Traceback (most recent call last):
File "C:UsersvikramworkspaceLDCtest.py", line 13, in <module>
driver.find_elements_by_link_text("MISCQA Misc Tests").click()
AttributeError: 'list' object has no attribute 'click'
Here is my program
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
import config
url = config.config.get('url')
driver = webdriver.Ie()
driver.get(url)
driver.find_elements_by_link_text("MISCQA Misc Tests").click()
driver.close()
I think I am missing some thing. Please suggest me
python selenium webdriver
driver.find_elements_by_link_text("MISCQA Misc Tests") returns list, not callable object
– cval
Jun 27 '12 at 9:22
add a comment |
I am trying to use click command in Selenium webdriver using python. But I am getting the below error. Can some one help me?
Traceback (most recent call last):
File "C:UsersvikramworkspaceLDCtest.py", line 13, in <module>
driver.find_elements_by_link_text("MISCQA Misc Tests").click()
AttributeError: 'list' object has no attribute 'click'
Here is my program
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
import config
url = config.config.get('url')
driver = webdriver.Ie()
driver.get(url)
driver.find_elements_by_link_text("MISCQA Misc Tests").click()
driver.close()
I think I am missing some thing. Please suggest me
python selenium webdriver
I am trying to use click command in Selenium webdriver using python. But I am getting the below error. Can some one help me?
Traceback (most recent call last):
File "C:UsersvikramworkspaceLDCtest.py", line 13, in <module>
driver.find_elements_by_link_text("MISCQA Misc Tests").click()
AttributeError: 'list' object has no attribute 'click'
Here is my program
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
import config
url = config.config.get('url')
driver = webdriver.Ie()
driver.get(url)
driver.find_elements_by_link_text("MISCQA Misc Tests").click()
driver.close()
I think I am missing some thing. Please suggest me
python selenium webdriver
python selenium webdriver
asked Jun 27 '12 at 9:19
vkrams
3,111135089
3,111135089
driver.find_elements_by_link_text("MISCQA Misc Tests") returns list, not callable object
– cval
Jun 27 '12 at 9:22
add a comment |
driver.find_elements_by_link_text("MISCQA Misc Tests") returns list, not callable object
– cval
Jun 27 '12 at 9:22
driver.find_elements_by_link_text("MISCQA Misc Tests") returns list, not callable object
– cval
Jun 27 '12 at 9:22
driver.find_elements_by_link_text("MISCQA Misc Tests") returns list, not callable object
– cval
Jun 27 '12 at 9:22
add a comment |
6 Answers
6
active
oldest
votes
Thanks for helping out. I found the answer for myself. Idea given by "Dan Niero"
The problem is, I am using driver.find_element[s]
instead of driver.find_element
. So one s makes difference. In fact I am following the eclipse :(. Obviously driver.find_elements_by_link_text
returns list so If i send click event it wont understand.
Thanks for helping and sorry for my bad question
-Vikram
add a comment |
maybe driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
or another index...
I don't know Selenium, but I guess find_elements_by_link_text is finding more than one thing, or maybe the method always return a list rather than a single object. If you are absolutely sure that only one object should be the result of your search, than just use [0] as I mentioned, if you can't assume that there will be only one object, than you need to come up with a stronger strategy
I used the above statement but no luck. do you think that I didn't import a correct class for it.
– vkrams
Jun 27 '12 at 9:29
1
Vikram, I don't know this Selenium, but the error message you got clearly states that you got a LIST back, so you need to access the elements inside that list... What other error you get when you try to do so?
– Dan Niero
Jun 27 '12 at 9:32
add a comment |
The part of your code,
driver.find_elements_by_link_text("MISCQA Misc Tests")
is returning back a list and not an object of the selenium webdriver (what you want, object of the class having the function "click()" ) .
Most likely, the elements of the list would be the objects.
Print the list after that part of the code and check if the elements of the list are the ones that you need.
This is the output which I get [<selenium.webdriver.remote.webelement.WebElement object at 0x0000000002D9E630>]
– vkrams
Jun 27 '12 at 9:26
WebDriver driver = new InternetExplorerDriver(); driver.get(url); WebElement element = driver.findElement(By.linkText("Miscellaneous Tests")); element.click(); - This is the code in Java. I want to simulate the same in Selenium Python
– vkrams
Jun 27 '12 at 9:28
1
Yes. these are objects itself. So, just iterate over the list and call the click() method over them. For example, driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
– user723556
Jun 27 '12 at 9:32
"returning back a list and not an object." Lists are object as well...
– glglgl
Jun 27 '12 at 9:33
1
^I meant not an object of the selenium webdriver he expects. Edited to make it more precise. Thank you for pointing that out. :)
– user723556
Jun 27 '12 at 9:34
add a comment |
if you want single element so u can use:
driver.find_element_by_link_text("MISCQA Misc Tests")
or if you want whole list, then:
for x in self.driver.find_elements_by_link_text("MISCQA Misc Tests"):
link = webdriver.ActionChains(self.driver).move_to_element(x).click(x).perform()
add a comment |
The statement driver.find_elements_by_link_text("MISCQA Misc Tests")
returns a list of WebElement some of which might not be clickable.
So you will have to loop through the list of WebElement's returned and then click on those elements which are clickable.
You can check if a WebElement is clickable or not by using the isClickable()
function.
I have not posted the code because I do not know Python. Hope this helps you.
isClickable() returns boolean so it doesn't require. Anyways I found the answer
– vkrams
Jun 27 '12 at 9:45
add a comment |
if the attribute of "MISCQA Misc Tests" only has one,You can try to change elements into element in this code 'driver.find_elements_by_link_text("MISCQA Misc Tests")'
Hope the problem will be fix
add a comment |
protected by Andersson Jul 12 '18 at 13:27
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for helping out. I found the answer for myself. Idea given by "Dan Niero"
The problem is, I am using driver.find_element[s]
instead of driver.find_element
. So one s makes difference. In fact I am following the eclipse :(. Obviously driver.find_elements_by_link_text
returns list so If i send click event it wont understand.
Thanks for helping and sorry for my bad question
-Vikram
add a comment |
Thanks for helping out. I found the answer for myself. Idea given by "Dan Niero"
The problem is, I am using driver.find_element[s]
instead of driver.find_element
. So one s makes difference. In fact I am following the eclipse :(. Obviously driver.find_elements_by_link_text
returns list so If i send click event it wont understand.
Thanks for helping and sorry for my bad question
-Vikram
add a comment |
Thanks for helping out. I found the answer for myself. Idea given by "Dan Niero"
The problem is, I am using driver.find_element[s]
instead of driver.find_element
. So one s makes difference. In fact I am following the eclipse :(. Obviously driver.find_elements_by_link_text
returns list so If i send click event it wont understand.
Thanks for helping and sorry for my bad question
-Vikram
Thanks for helping out. I found the answer for myself. Idea given by "Dan Niero"
The problem is, I am using driver.find_element[s]
instead of driver.find_element
. So one s makes difference. In fact I am following the eclipse :(. Obviously driver.find_elements_by_link_text
returns list so If i send click event it wont understand.
Thanks for helping and sorry for my bad question
-Vikram
edited Sep 25 '13 at 22:32
alecxe
322k64620845
322k64620845
answered Jun 27 '12 at 9:42
vkrams
3,111135089
3,111135089
add a comment |
add a comment |
maybe driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
or another index...
I don't know Selenium, but I guess find_elements_by_link_text is finding more than one thing, or maybe the method always return a list rather than a single object. If you are absolutely sure that only one object should be the result of your search, than just use [0] as I mentioned, if you can't assume that there will be only one object, than you need to come up with a stronger strategy
I used the above statement but no luck. do you think that I didn't import a correct class for it.
– vkrams
Jun 27 '12 at 9:29
1
Vikram, I don't know this Selenium, but the error message you got clearly states that you got a LIST back, so you need to access the elements inside that list... What other error you get when you try to do so?
– Dan Niero
Jun 27 '12 at 9:32
add a comment |
maybe driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
or another index...
I don't know Selenium, but I guess find_elements_by_link_text is finding more than one thing, or maybe the method always return a list rather than a single object. If you are absolutely sure that only one object should be the result of your search, than just use [0] as I mentioned, if you can't assume that there will be only one object, than you need to come up with a stronger strategy
I used the above statement but no luck. do you think that I didn't import a correct class for it.
– vkrams
Jun 27 '12 at 9:29
1
Vikram, I don't know this Selenium, but the error message you got clearly states that you got a LIST back, so you need to access the elements inside that list... What other error you get when you try to do so?
– Dan Niero
Jun 27 '12 at 9:32
add a comment |
maybe driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
or another index...
I don't know Selenium, but I guess find_elements_by_link_text is finding more than one thing, or maybe the method always return a list rather than a single object. If you are absolutely sure that only one object should be the result of your search, than just use [0] as I mentioned, if you can't assume that there will be only one object, than you need to come up with a stronger strategy
maybe driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
or another index...
I don't know Selenium, but I guess find_elements_by_link_text is finding more than one thing, or maybe the method always return a list rather than a single object. If you are absolutely sure that only one object should be the result of your search, than just use [0] as I mentioned, if you can't assume that there will be only one object, than you need to come up with a stronger strategy
edited Sep 25 '13 at 22:32
alecxe
322k64620845
322k64620845
answered Jun 27 '12 at 9:27
Dan Niero
610415
610415
I used the above statement but no luck. do you think that I didn't import a correct class for it.
– vkrams
Jun 27 '12 at 9:29
1
Vikram, I don't know this Selenium, but the error message you got clearly states that you got a LIST back, so you need to access the elements inside that list... What other error you get when you try to do so?
– Dan Niero
Jun 27 '12 at 9:32
add a comment |
I used the above statement but no luck. do you think that I didn't import a correct class for it.
– vkrams
Jun 27 '12 at 9:29
1
Vikram, I don't know this Selenium, but the error message you got clearly states that you got a LIST back, so you need to access the elements inside that list... What other error you get when you try to do so?
– Dan Niero
Jun 27 '12 at 9:32
I used the above statement but no luck. do you think that I didn't import a correct class for it.
– vkrams
Jun 27 '12 at 9:29
I used the above statement but no luck. do you think that I didn't import a correct class for it.
– vkrams
Jun 27 '12 at 9:29
1
1
Vikram, I don't know this Selenium, but the error message you got clearly states that you got a LIST back, so you need to access the elements inside that list... What other error you get when you try to do so?
– Dan Niero
Jun 27 '12 at 9:32
Vikram, I don't know this Selenium, but the error message you got clearly states that you got a LIST back, so you need to access the elements inside that list... What other error you get when you try to do so?
– Dan Niero
Jun 27 '12 at 9:32
add a comment |
The part of your code,
driver.find_elements_by_link_text("MISCQA Misc Tests")
is returning back a list and not an object of the selenium webdriver (what you want, object of the class having the function "click()" ) .
Most likely, the elements of the list would be the objects.
Print the list after that part of the code and check if the elements of the list are the ones that you need.
This is the output which I get [<selenium.webdriver.remote.webelement.WebElement object at 0x0000000002D9E630>]
– vkrams
Jun 27 '12 at 9:26
WebDriver driver = new InternetExplorerDriver(); driver.get(url); WebElement element = driver.findElement(By.linkText("Miscellaneous Tests")); element.click(); - This is the code in Java. I want to simulate the same in Selenium Python
– vkrams
Jun 27 '12 at 9:28
1
Yes. these are objects itself. So, just iterate over the list and call the click() method over them. For example, driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
– user723556
Jun 27 '12 at 9:32
"returning back a list and not an object." Lists are object as well...
– glglgl
Jun 27 '12 at 9:33
1
^I meant not an object of the selenium webdriver he expects. Edited to make it more precise. Thank you for pointing that out. :)
– user723556
Jun 27 '12 at 9:34
add a comment |
The part of your code,
driver.find_elements_by_link_text("MISCQA Misc Tests")
is returning back a list and not an object of the selenium webdriver (what you want, object of the class having the function "click()" ) .
Most likely, the elements of the list would be the objects.
Print the list after that part of the code and check if the elements of the list are the ones that you need.
This is the output which I get [<selenium.webdriver.remote.webelement.WebElement object at 0x0000000002D9E630>]
– vkrams
Jun 27 '12 at 9:26
WebDriver driver = new InternetExplorerDriver(); driver.get(url); WebElement element = driver.findElement(By.linkText("Miscellaneous Tests")); element.click(); - This is the code in Java. I want to simulate the same in Selenium Python
– vkrams
Jun 27 '12 at 9:28
1
Yes. these are objects itself. So, just iterate over the list and call the click() method over them. For example, driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
– user723556
Jun 27 '12 at 9:32
"returning back a list and not an object." Lists are object as well...
– glglgl
Jun 27 '12 at 9:33
1
^I meant not an object of the selenium webdriver he expects. Edited to make it more precise. Thank you for pointing that out. :)
– user723556
Jun 27 '12 at 9:34
add a comment |
The part of your code,
driver.find_elements_by_link_text("MISCQA Misc Tests")
is returning back a list and not an object of the selenium webdriver (what you want, object of the class having the function "click()" ) .
Most likely, the elements of the list would be the objects.
Print the list after that part of the code and check if the elements of the list are the ones that you need.
The part of your code,
driver.find_elements_by_link_text("MISCQA Misc Tests")
is returning back a list and not an object of the selenium webdriver (what you want, object of the class having the function "click()" ) .
Most likely, the elements of the list would be the objects.
Print the list after that part of the code and check if the elements of the list are the ones that you need.
edited Jun 27 '12 at 9:35
answered Jun 27 '12 at 9:25
user723556
This is the output which I get [<selenium.webdriver.remote.webelement.WebElement object at 0x0000000002D9E630>]
– vkrams
Jun 27 '12 at 9:26
WebDriver driver = new InternetExplorerDriver(); driver.get(url); WebElement element = driver.findElement(By.linkText("Miscellaneous Tests")); element.click(); - This is the code in Java. I want to simulate the same in Selenium Python
– vkrams
Jun 27 '12 at 9:28
1
Yes. these are objects itself. So, just iterate over the list and call the click() method over them. For example, driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
– user723556
Jun 27 '12 at 9:32
"returning back a list and not an object." Lists are object as well...
– glglgl
Jun 27 '12 at 9:33
1
^I meant not an object of the selenium webdriver he expects. Edited to make it more precise. Thank you for pointing that out. :)
– user723556
Jun 27 '12 at 9:34
add a comment |
This is the output which I get [<selenium.webdriver.remote.webelement.WebElement object at 0x0000000002D9E630>]
– vkrams
Jun 27 '12 at 9:26
WebDriver driver = new InternetExplorerDriver(); driver.get(url); WebElement element = driver.findElement(By.linkText("Miscellaneous Tests")); element.click(); - This is the code in Java. I want to simulate the same in Selenium Python
– vkrams
Jun 27 '12 at 9:28
1
Yes. these are objects itself. So, just iterate over the list and call the click() method over them. For example, driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
– user723556
Jun 27 '12 at 9:32
"returning back a list and not an object." Lists are object as well...
– glglgl
Jun 27 '12 at 9:33
1
^I meant not an object of the selenium webdriver he expects. Edited to make it more precise. Thank you for pointing that out. :)
– user723556
Jun 27 '12 at 9:34
This is the output which I get [<selenium.webdriver.remote.webelement.WebElement object at 0x0000000002D9E630>]
– vkrams
Jun 27 '12 at 9:26
This is the output which I get [<selenium.webdriver.remote.webelement.WebElement object at 0x0000000002D9E630>]
– vkrams
Jun 27 '12 at 9:26
WebDriver driver = new InternetExplorerDriver(); driver.get(url); WebElement element = driver.findElement(By.linkText("Miscellaneous Tests")); element.click(); - This is the code in Java. I want to simulate the same in Selenium Python
– vkrams
Jun 27 '12 at 9:28
WebDriver driver = new InternetExplorerDriver(); driver.get(url); WebElement element = driver.findElement(By.linkText("Miscellaneous Tests")); element.click(); - This is the code in Java. I want to simulate the same in Selenium Python
– vkrams
Jun 27 '12 at 9:28
1
1
Yes. these are objects itself. So, just iterate over the list and call the click() method over them. For example, driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
– user723556
Jun 27 '12 at 9:32
Yes. these are objects itself. So, just iterate over the list and call the click() method over them. For example, driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
– user723556
Jun 27 '12 at 9:32
"returning back a list and not an object." Lists are object as well...
– glglgl
Jun 27 '12 at 9:33
"returning back a list and not an object." Lists are object as well...
– glglgl
Jun 27 '12 at 9:33
1
1
^I meant not an object of the selenium webdriver he expects. Edited to make it more precise. Thank you for pointing that out. :)
– user723556
Jun 27 '12 at 9:34
^I meant not an object of the selenium webdriver he expects. Edited to make it more precise. Thank you for pointing that out. :)
– user723556
Jun 27 '12 at 9:34
add a comment |
if you want single element so u can use:
driver.find_element_by_link_text("MISCQA Misc Tests")
or if you want whole list, then:
for x in self.driver.find_elements_by_link_text("MISCQA Misc Tests"):
link = webdriver.ActionChains(self.driver).move_to_element(x).click(x).perform()
add a comment |
if you want single element so u can use:
driver.find_element_by_link_text("MISCQA Misc Tests")
or if you want whole list, then:
for x in self.driver.find_elements_by_link_text("MISCQA Misc Tests"):
link = webdriver.ActionChains(self.driver).move_to_element(x).click(x).perform()
add a comment |
if you want single element so u can use:
driver.find_element_by_link_text("MISCQA Misc Tests")
or if you want whole list, then:
for x in self.driver.find_elements_by_link_text("MISCQA Misc Tests"):
link = webdriver.ActionChains(self.driver).move_to_element(x).click(x).perform()
if you want single element so u can use:
driver.find_element_by_link_text("MISCQA Misc Tests")
or if you want whole list, then:
for x in self.driver.find_elements_by_link_text("MISCQA Misc Tests"):
link = webdriver.ActionChains(self.driver).move_to_element(x).click(x).perform()
edited Jul 27 '16 at 13:12
Ulf Gjerdingen
1,27531319
1,27531319
answered Jul 27 '16 at 12:21
priya
111
111
add a comment |
add a comment |
The statement driver.find_elements_by_link_text("MISCQA Misc Tests")
returns a list of WebElement some of which might not be clickable.
So you will have to loop through the list of WebElement's returned and then click on those elements which are clickable.
You can check if a WebElement is clickable or not by using the isClickable()
function.
I have not posted the code because I do not know Python. Hope this helps you.
isClickable() returns boolean so it doesn't require. Anyways I found the answer
– vkrams
Jun 27 '12 at 9:45
add a comment |
The statement driver.find_elements_by_link_text("MISCQA Misc Tests")
returns a list of WebElement some of which might not be clickable.
So you will have to loop through the list of WebElement's returned and then click on those elements which are clickable.
You can check if a WebElement is clickable or not by using the isClickable()
function.
I have not posted the code because I do not know Python. Hope this helps you.
isClickable() returns boolean so it doesn't require. Anyways I found the answer
– vkrams
Jun 27 '12 at 9:45
add a comment |
The statement driver.find_elements_by_link_text("MISCQA Misc Tests")
returns a list of WebElement some of which might not be clickable.
So you will have to loop through the list of WebElement's returned and then click on those elements which are clickable.
You can check if a WebElement is clickable or not by using the isClickable()
function.
I have not posted the code because I do not know Python. Hope this helps you.
The statement driver.find_elements_by_link_text("MISCQA Misc Tests")
returns a list of WebElement some of which might not be clickable.
So you will have to loop through the list of WebElement's returned and then click on those elements which are clickable.
You can check if a WebElement is clickable or not by using the isClickable()
function.
I have not posted the code because I do not know Python. Hope this helps you.
answered Jun 27 '12 at 9:43
Hari Reddy
3,11522637
3,11522637
isClickable() returns boolean so it doesn't require. Anyways I found the answer
– vkrams
Jun 27 '12 at 9:45
add a comment |
isClickable() returns boolean so it doesn't require. Anyways I found the answer
– vkrams
Jun 27 '12 at 9:45
isClickable() returns boolean so it doesn't require. Anyways I found the answer
– vkrams
Jun 27 '12 at 9:45
isClickable() returns boolean so it doesn't require. Anyways I found the answer
– vkrams
Jun 27 '12 at 9:45
add a comment |
if the attribute of "MISCQA Misc Tests" only has one,You can try to change elements into element in this code 'driver.find_elements_by_link_text("MISCQA Misc Tests")'
Hope the problem will be fix
add a comment |
if the attribute of "MISCQA Misc Tests" only has one,You can try to change elements into element in this code 'driver.find_elements_by_link_text("MISCQA Misc Tests")'
Hope the problem will be fix
add a comment |
if the attribute of "MISCQA Misc Tests" only has one,You can try to change elements into element in this code 'driver.find_elements_by_link_text("MISCQA Misc Tests")'
Hope the problem will be fix
if the attribute of "MISCQA Misc Tests" only has one,You can try to change elements into element in this code 'driver.find_elements_by_link_text("MISCQA Misc Tests")'
Hope the problem will be fix
answered Apr 14 '17 at 7:54
sherry
1
1
add a comment |
add a comment |
protected by Andersson Jul 12 '18 at 13:27
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
driver.find_elements_by_link_text("MISCQA Misc Tests") returns list, not callable object
– cval
Jun 27 '12 at 9:22