i have a error in automation

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

driver = webdriver.Chrome(chromedriver)
driver.get('https://web.whatsapp.com/')

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))

 

user.click()

msg_box = driver.find_element_by_class_name('wjdTm')

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

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
    self.error_handler.check_response(response)
  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 15, 2019 in Selenium by anonymous
• 120 points
733 views
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, 2019 by Abha
• 28,060 points

Related Questions In Selenium

+3 votes
1 answer

How to read excel file numeric data of all rows and column in selenium? I have 10 rows and 5 column but I read Only String value not a Numeric value?

Hey, @Mahendra, check this thread https://www.edureka.co/community/52170/read-numeric-data-from-excel-sheet-using-selenium-webdriver It deals with ...READ MORE

answered Jan 27, 2020 in Selenium by Sirajul
• 59,090 points
853 views
0 votes
0 answers

URGENT ! I have a problem in my code. Please Help!!

Hello, I tried to extract data from a ...READ MORE

Apr 24, 2020 in Selenium by anonymous
• 120 points
209 views
0 votes
1 answer
+1 vote
0 answers

how can read text from website ??

from selenium import webdriver import time query = ('maps') if ...READ MORE

Jan 7, 2020 in Python by anonymous
• 130 points
275 views
0 votes
2 answers

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,500 points
6,205 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
6,568 views
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,890 points
4,190 views
0 votes
2 answers

What is a headless browser in automation testing and what are it's benefits?

Hi Sanaya, a headless browser is a web browser ...READ MORE

answered Aug 1, 2019 in Selenium by Abha
• 28,060 points
2,233 views
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 20, 2019 in Selenium by Abha
• 28,060 points
1,378 views