i have a error in automation

0 votes
from selenium import webdriver
chromedriver = "/Users/ROJA/Downloads/chromedriver"

driver = webdriver.Chrome(chromedriver)

name = input('Enter the name of user or group : ')
msg = input('Enter your message : ')
count = int(input('Enter the count : '))

input('Enter anything after scanning QR code')

#ths is an error
user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))



msg_box = driver.find_element_by_class_name('wjdTm')

for i in range(count):
    button = driver.find_element_by_class_name('_3M-N-')

this is a output :

Enter the name of user or group : Bp
Enter your message : ur hacked
Enter the count : 50
Enter anything after scanning QR code
Traceback (most recent call last):
  File "automation.py", line 87, in <module>
    user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))
  File "C:\Users\ROJA\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "C:\Users\ROJA\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
    'value': value})['value']
  File "C:\Users\ROJA\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
  File "C:\Users\ROJA\AppData\Local\Programs\Python\Python37-32\lib\site-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":"//span[@title = "Bp"]"}
  (Session info: chrome=77.0.3865.90)

please solve as  soon as possible
Oct 14 in Selenium by anonymous
• 120 points
Seems like there is no user by the name that you have entered. Please confirm that

1 answer to this question.

0 votes

Instead of using Xpath, can you use id or any other identifier to locate the user element. Also add implicit or explicit wait so that page load can be done properly. 

"NoSuchElementException: Message: no such element: Unable to locate element:" These kind of errors occur when page load takes time or any specific element takes time to load properly. So using Wait or Thread.sleep() might help you.

answered Oct 15 by Abha
• 27,180 points

Related Questions In Selenium

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

Getting error while running a XML file in TestNG

Hello @Sradha, The synatx of using test is ...READ MORE

answered Dec 26, 2018 in Selenium by Rashmi
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
0 votes
2 answers
0 votes
1 answer

How can I skip a @Test method from execution in TestNG?

Hey Darsh, you can skip a @Test ...READ MORE

answered Jun 19 in Selenium by Abha
• 27,180 points