Element not found exception while executing the script

35 views
Skip to first unread message

Shweta Choubey

unread,
Jul 4, 2020, 12:49:20 AM7/4/20
to Selenium Users
Hi All,

I have been automating one CRM application, where I have found correct Xpath, and when I am using this Xpath in the script it shows element not found exception. There is no frame in the application and I have applied the wait statement as well, but still the same exception. Could anyone please help me with this.

Radhika Joshi

unread,
Jul 4, 2020, 8:28:46 AM7/4/20
to seleniu...@googlegroups.com
What is the code?

Have you tried using webdriverwait?
(Wait for element to be visible ) or even thread.sleep?

Regards
Radhika Joshi

On Sat, 4 Jul 2020, 10:19 Shweta Choubey, <shweta.c...@gmail.com> wrote:
Hi All,

I have been automating one CRM application, where I have found correct Xpath, and when I am using this Xpath in the script it shows element not found exception. There is no frame in the application and I have applied the wait statement as well, but still the same exception. Could anyone please help me with this.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/579fddb8-37b9-4aba-afb7-c2faf271eed1o%40googlegroups.com.

Shweta Choubey

unread,
Jul 6, 2020, 12:57:06 AM7/6/20
to Selenium Users
yes Radhika, here is my code

public void createNewCompany(String company_name) throws InterruptedException
{
WebDriverWait wait1 = new WebDriverWait(driver, 20);
  wait1.until(
  ExpectedConditions.visibilityOfElementLocated((By.xpath(".//button[text()='New']"))));
newCompanyBtn.click();
//****************
  WebDriverWait wait = new WebDriverWait(driver, 50);
  wait.until(
  ExpectedConditions.visibilityOfElementLocated((By.xpath("//div[@class='ui right corner labeled input']//input[@name='name']"))));
  
 
//*************************************
nameOfCompany.sendKeys(company_name);
saveBtn.click();
}

And here is the DOM:

Capture.PNG



On Saturday, July 4, 2020 at 5:58:46 PM UTC+5:30, Radhika Joshi wrote:
What is the code?

Have you tried using webdriverwait?
(Wait for element to be visible ) or even thread.sleep?

Regards
Radhika Joshi
On Sat, 4 Jul 2020, 10:19 Shweta Choubey, <shweta....@gmail.com> wrote:
Hi All,

I have been automating one CRM application, where I have found correct Xpath, and when I am using this Xpath in the script it shows element not found exception. There is no frame in the application and I have applied the wait statement as well, but still the same exception. Could anyone please help me with this.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seleniu...@googlegroups.com.

Radhika Joshi

unread,
Jul 6, 2020, 1:11:02 AM7/6/20
to seleniu...@googlegroups.com
Hey 
can you send me the exact line where the exception is being found?

Thanks & Regards
Radhika Joshi

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/105c49c0-482b-43f8-936d-27250cde60f8o%40googlegroups.com.

Joel

unread,
Jul 6, 2020, 1:48:38 PM7/6/20
to Selenium Users
Welcome to Selenium, land of endless disappointment and frustration. 

Without seeing the application we can't *really* help, but if you're consistently getting this error than you have not found the correct Xpath. You might want to try css selectors to see if you can get any further. Also see if you can locate elements near the one you are interested in, you might discover another approach. 

Is there anything notable about this particular element behavior, i.e. does it only appear in response to another action? 

Good luck. 

Joel

unread,
Jul 6, 2020, 1:54:33 PM7/6/20
to Selenium Users
Just looked at your code snippet. Where is the definition of nameOfCompany element? 

D Sandeep

unread,
Jul 6, 2020, 2:13:09 PM7/6/20
to seleniu...@googlegroups.com
There is not button with text ='New'..

On which line are you having the issue

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/105c49c0-482b-43f8-936d-27250cde60f8o%40googlegroups.com.

Shweta Choubey

unread,
Jul 6, 2020, 2:22:03 PM7/6/20
to Selenium Users
Hi Joel,

Following is the site which I am trying to automate "https://ui.cogmento.com/" when you log in to this site, it had the option of creating a new company. Another point is that when running in debug mode the same script is giving proper results. Don't know what is the problem when the actual script is running.

Joel

unread,
Jul 6, 2020, 3:52:23 PM7/6/20
to Selenium Users
Had a quick look, I as able to locate in console with $("[placeholder][name]") so you might want to try something along those lines. Also, the element doesn't exist until after you click the New button, so make sure you create nameOfCompany after the new company page is displayed. 
Reply all
Reply to author
Forward
0 new messages