I am trying to click over a link using xpath locator , but the click is not happening. Also I dont get any error or exception. I have checked with selenium IDE that the path I am providing is correct to recognize the link.
Here is my code is
driver.findElement(By.xpath("//div[#class='bpm-social-task-row-data-header']/span/a")).click();
I have also tried this
WebElement steplink = driver.findElement(By.xpath("//div[#class='bpm-social-task-row-data-header']/span/a"));
System.out.println("steplink properties " + steplink.getText());
steplink.hover();
steplink.click();
This also giving same result.
Related
Does RobotFramework have any way of finding a link's URL to then paste into same browser and goto it in same window. The link exists in a button/link on the first page.
Reason i ask is because it opens a new window (which i dont want it to do)
You can use Get element attribute to get the value of the href attribute.
Here is an example using an xpath to find the element:
*** Settings ***
Library Selenium2Library
Suite Setup open browser about:blank chrome
Suite Teardown close all browsers
*** Test cases ***
Example
go to http://www.example.com
${url}= get element attribute xpath=//a[text()='More information...'] href
Should be equal ${url} http://www.iana.org/domains/example
I have the below code in Appium to automate mobile application.
MobileElement objelement=null;
wait = new WebDriverWait(mobileDriveriOS, 15);
objelement=(MobileElement)mobileDriveriOS.findElement(By.xpath("UIAApplication[1]/UIAWindow[1]/UIATextField[1]/UIATextField[1]"));
objelement.sendKeys("Test");
Here mobileDriveriOS is an object of type iOS driver.
Instead of 'sendKeys' tried with click also it dint work out.
The error is "An element could not be located on the page using the given search parameters"
Your xpath query is missing the first two slashes from search criteria. This should work better:
objelement=(MobileElement)mobileDriveriOS.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATextField[1]/UIATextField[1]"));
I have been hit with InvalidSelectorException on a regular basis when i run my selenium web driver test script
My test fails with this InvalidSelector Exception and throws message as :
The xpath expression '//form[#name=somelocator]' cannot be evaluated or does not result in a WebElement
The element locator i use is perfect which return a correct web element when i cross verify it using xpath checker / or with browser console, so no issue with the element locator
I click on some button and then wait for the above xpath locator element to load in the application UI and giving enough waitTilllElementVisible() methods before checking the above locator
I found that many faced this issue, but could not get the concrete reason for this failure.
Selenium asks to visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html for the documentation on this error, but this link looks not up
Reproduced it with selenium 2.45 and 2.46 version with IE11
Please let me know if you knows the reason for this and why it throws invalidSelector exception on browser open with webdriver
I think the problem is the SPACE character in the #name tag. Try "//form[#name='some locator']" or '//form[#name=\'some locator\']'.
#peetya's answer is probably correct and a better answer but I prefer CSS Selectors... they are less error prone if you have the option to not use XPath.
driver.findElement(By.cssSelector("form[name='some locator']"));
CSS Selector reference
I am working on QTP 11. I my current project I am trying to automate a website with AJAX fields. I my project I have a text field on which if we try to enter characters then AJAX table appears and we have select a suitable value from the below table. I am able to check the existence of AJAX table.
The problem is to set the text field through QTP, AJAX is not getting invoked. But manually it is working properly. Also, if I first try manually and then I try to enter any through the script, then also it is working properly. It is not possible for me to check each field manually then enter it through script. So can any body tell how AJAX can be invoked on first try without any manual intervention?
I have tried to Set property, Keyboard events like WScript.shell, Mercury.DeviceReplay and AutoIt, however none of them are working. Are there any keyboard input methods that I have missed out?
Can somebody please help me out?
Try performing a WebEdit.Click on the text field in question. If this doesn't work it means that the web page is expecting some events that QTP didn't fire in this case you should change to device replay mode
Setting.WebPackage("ReplayType") = 2
Browser(...).Page(...).WebEdit(...).Click
Setting.WebPackage("ReplayType") = 1
I had the same issue, not recognizing the web list (not selecting the item from list). Using QTP 11.5 loaded with web toolkit 2.0, ASPAjax, DOJO, JQuery add-ins. Still showing the same behavior.
However there is nothing wrong with the code, if I give some wait the code is working OK.
I am looking at the website. Trying to transfer selenium html to junit but could not get it to work because it keeps saying Error: Element not found. Maybe syntax error because I was able to break it down to the shortest path in firebug but still could not get to compile..What do you do in this case ?
Enrollment
I use firebug Xpath to get the value of the above link
/html/body/div[#id='contentDisplayPane']/div[#id='mainDiv']/div[#id='mainDivContent']/div[#id='simpleBox']/table/tbody/tr[2]/td[#id='fb_PageContent']/table/tbody/tr/td/table/tbody/tr/td[4]/a
Using firebug xpath, I was able to break it down to this and able to access Enrollment link..However when I put this in the junit test case selenium.click(("//div[#id='simpleBox']/table/tbody/tr[2]/td[#id='fb_PageContent']/table/tbody/tr/td/table/tbody/tr/td[4]/a");
I get ERROR: Element //div[#id='simpleBox']/table/tbody/tr[2]/td[#id='fb_PageContent']/table/tbody/tr/td/table/tbody/tr/td[4]/a") not found
Any help or tip is appreciated
Hey If you want to click any Link on your web page.
You have to first find Xpath of this Element/Text, For this you can use Firebug.So here an ex: You can use in IDE selenium.click(//a[text()="ON"]) and convert it to junit and get this
selenium.click("//a[text()=\"HereYouCanPutYourText\"]");
please feel free if you have any concern..
Are the tbody elements actually in the html or just being inserted by Firefox? If Firefox is inserting the tbody and your junit tests are driving a different browser, the tbody might not be there. Just a shot in the dark since you didn't post the document you're testing, but maybe it'll help.