Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium IDE, [error] Element name.... not found

Tags:

selenium

Trying Selenium IDE. I'm getting an intermittent error, I've tried slowing down the IDE but it still happens. I start w/google and search for fishbase, I then click search fishbase link - then "common name is" and I put Taron in and like the top-most "usa" link. Usually it gets error at the same place "[error] Element name=CommonName not found", 9 times out of ten it has a problem there. I hope I've provided enough info. Using Ubuntu 11.10 and FF 11.0. I have a very fast connection but move the slider to slow. Why does this problem occur?

<tr>
    <td>open</td>
    <td>/</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>id=gbqfq</td>
    <td>fishbase</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>css=em</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>name=CommonName</td>
    <td>Tarpon</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>css=input[type=&quot;button&quot;]</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>link=Tarpon</td>
    <td></td>
</tr>

It worked the 1st time but not the 2nd time...thanks.

[info] Executing: |open | / | |
[info] Executing: |type | id=gbqfq | fishbase |
[info] Executing: |clickAndWait | css=em | |
[info] Executing: |type | name=CommonName | Tarpon |
[info] Executing: |clickAndWait | css=input[type="button"] | |
[info] Executing: |clickAndWait | link=Tarpon | |
[info] Executing: |open | / | |
[info] Executing: |type | id=gbqfq | fishbase |
[info] Executing: |clickAndWait | css=em | |
[info] Executing: |type | name=CommonName | Tarpon |
[error] Element name=CommonName not found 
like image 360
user1325143 Avatar asked Apr 11 '12 04:04

user1325143


People also ask

How to handle if element is not found in Selenium?

To achieve this, we shall use the method getPageSource which gets the entire page source. So we can obtain a complete page source and check if the text of the element exists. We also use the findElements method and utilize any locators like xpath, CSS, and so on to identify the matching elements.

How to continue script when element is not found in Selenium Python?

There are multiple ways to achieve this. We can introduce a try / except block. In the except block, we shall throw the NoSuchElementException in case the element does not exist on the page. We can also verify if an element is present in the page, with the help of find_elements() method.


1 Answers

This will solve your problem

 <tr>
        <td>click</td>
        <td>css=em</td>
        <td></td>
    </tr>
    <tr>
        <td>pause</td>
        <td>7000</td>
        <td></td>
    </tr>
    <tr>
        <td>type</td>
        <td>name=CommonName</td>
        <td>Tarpon</td>
    </tr>

Or just put pause before command type| name=CommonName |Tarpon

like image 69
Rohit Ware Avatar answered Sep 20 '22 04:09

Rohit Ware