Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
Lahari
Posts : 5
Join date : 2009-08-03

How to write a prg for selenium.click(//a[3]/img); in java Empty How to write a prg for selenium.click(//a[3]/img); in java

Mon Aug 03, 2009 2:23 pm
Hi,

Gr8 to see everyone...
In Selenium RC
How to write a prg for selenium.click(//a[3]/img); in java.

Thank for u r good support.

Yours

Lahari.
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

How to write a prg for selenium.click(//a[3]/img); in java Empty A sample java code as per requirement.

Tue Aug 04, 2009 10:52 am
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;



public class Sample extends SeleneseTestCase
{
public Selenium browser;

public static void main(String arg[]) throws InterruptedException
{
Sample obj = new Sample ();
obj.setUp();
}

public void setUp() throws InterruptedException
{
browser = new DefaultSelenium("localhost",4444,"*iexplore","http://google.com");
browser.start();
browser.open("http://google.com");
browser.windowMaximize();
browser.type("q", "selenium");
browser.click("btnG");
browser.waitForPageToLoad("30000");

}


}


NOTE: For running this code you have to link you project or program to a selenium and Junit jar. After linking the jar to the editor. You can compile it and run it. This code will open a google site, enter selenium and click on search button. Finally result will display. I used eclipse for coding in java and link all jar file to the project.

As per your question , if you want to click on a link which u provide in question. Just change the URL name of your application and use the click command given in above code.

I hope this will help you. Very Happy cheers
avatar
Lahari
Posts : 5
Join date : 2009-08-03

How to write a prg for selenium.click(//a[3]/img); in java Empty Re: How to write a prg for selenium.click(//a[3]/img); in java

Tue Aug 11, 2009 7:20 pm
Hi Admin,
Thank u so much for u r help.
I am unable to execute ur code in Junit code.
Find the below details u can understand where i am getting problem.
On executing the application in Selenium IDE generated the below script.

public class NewTest extends SeleneseTestCase
{

public void setUp() throws Exception
{

setUp("http://1.0.0.2/","*chrome");
public void testNew() throws Exception
{

selenium.open("/sample/checkUserSession.do?method=checkUserSession&status=active&msg=");

selenium.type("userId","admin");
selenium.type("password","1234");
selenium.click("mybutton");
selenium.waitForPageToLoad("30000");
selenium.click("//a[3]/img");-> (This code is generated for Logout operation)
assertTrue(selenium.getConfirmation().matches ("^Do you want to LogOut [\\s\\S]$"));

In Selenium RC executing the same script.I am getting error “
Element id not found” in this selenium.click("//a[3]/img"); line.


From front end Logout is a button.But it is a Image.
how to run selenium.click("//a[3]/img") in Selenium RC.
Plz help me

Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

How to write a prg for selenium.click(//a[3]/img); in java Empty Re: How to write a prg for selenium.click(//a[3]/img); in java

Wed Aug 12, 2009 11:45 am
hi,

There may be many reasons for this like:

1. waitforpageload command is not waiting till time specified and control moves further when page is still loading. Try to debug code line by line and see.

2. The locator is not exactly same appear on screen. try to use xpath or dom locator. May be that id generated on run time and change every time.

3. before click command place verifyElementPresent command to debug.

Try all this and let me know. I hope this will help u

Bye
avatar
Lahari
Posts : 5
Join date : 2009-08-03

How to write a prg for selenium.click(//a[3]/img); in java Empty Thx its working

Wed Aug 12, 2009 6:33 pm
Thx.
Very Happy its working
avatar
senthilm.aynara
Active particpant
Active particpant
Posts : 19
Join date : 2009-09-15

How to write a prg for selenium.click(//a[3]/img); in java Empty Re: How to write a prg for selenium.click(//a[3]/img); in java

Tue Sep 15, 2009 6:41 pm
Lahari wrote:Thx.
How to write a prg for selenium.click(//a[3]/img); in java Icon_biggrin its working

Hi I am facing the same problem. can u tell me how did u solve the problem?

Thanks & Regards,
senthilm
avatar
lasombra
Posts : 1
Join date : 2009-11-26

How to write a prg for selenium.click(//a[3]/img); in java Empty Re: How to write a prg for selenium.click(//a[3]/img); in java

Thu Nov 26, 2009 6:44 pm
Hi all
I try to click an element (an img within a div tag). I first check if the element I am looking for is present, which returns true:
selenium.isElementPresent(elem
whereas elem = "//div[@id='menuTree1']/img[1]"
But when I want to click on that element
selenium.click(elem)
An exception is raised:
com.thoughtworks.selenium.SeleniumException: ERROR: Element //div[@id='menuTree1']/img[1] not found
The element I want to access is within a frame, within an iframe, which I select before:

selenium.selectFrame(frame);
selenium.selectFrame("index=1");


Thanks for your help, lasombra
Sponsored content

How to write a prg for selenium.click(//a[3]/img); in java Empty Re: How to write a prg for selenium.click(//a[3]/img); in java

Back to top
Permissions in this forum:
You cannot reply to topics in this forum