Selenium : webdriver did not recognized the webelement - webdriver

Can any one figure out this issue
I generated the script for login page, after login i wanted to log out the app or perform some action on that current page but i failed to do so. I performed by xpath,name,id. I also put thread.sleep but system gave me such error.
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"LnkLogoff"}
Command duration or timeout: 30.52 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_22'
Session ID: 187840f8-dc3c-4885-ae8a-6192dae1b552
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=20.0.1, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:348)
at org.openqa.selenium.By$ById.findElement(By.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
at testsuite.n2.main(n2.java:39)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to locate element: {"method":"id","selector":"LnkLogoff"}
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_22'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/DOCUME~1/NCHAUD~1/LOCALS~1/Temp/anonymous526938929382849157webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js:8405)
at <anonymous class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/DOCUME~1/NCHAUD~1/LOCALS~1/Temp/anonymous526938929382849157webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js:386)

Related

RSelenium cannot connect to Chrome

I am setting up Selenium in R
library(RSelenium)
rD <- RSelenium::rsDriver(browser="chrome")
When i run rsDriver(), it brought up chrome and gave the following errors
[1] "Connecting to remote server"
Selenium message:unknown error: unable to discover open pages
(Driver info: chromedriver=71.0.3578.33 (269aa0e3f0db08097f0fe231c7e6be200b6939f7),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.99 seconds
Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:47'
System info: host: 'ELI-T460', ip: '172.xx.xx.xx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_191'
Driver info: driver.version: unknown
Could not open chrome browser.
Client error message:
Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
Further Details: run errorDetails method
Check server log for further details.
I have tried to run with older version of chromedriver and it gave the same error.

How to start chrome from R console with ChromeDriver and RSelenium?

I am trying to open chrome from R console using command
> remDr <- remoteDriver(remoteServerAddr = "localhost" , port = 4444 , browserName = "chrome")
> remDr$open()
the versions are all latest.
chrome - 55
chromedriver - 2.27
selenium standalone server - 3.0.1
I am able to connect to remote server with following error message but it doesn't open the browser.
$message
[1] "unknown error: Chrome failed to start: exited abnormally\n (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64)"
but when i try to navigate, it throws following error,
> remDr <- remoteDriver(remoteServerAddr = "localhost" , port = 4444 , browserName = "chrome")
> remDr$open()
[1] "Connecting to remote server"
$webdriver.remote.sessionid
[1] "17e6e349-9a67-4423-a817-1798a3e60933"
$locationContextEnabled
[1] TRUE
$webStorageEnabled
[1] TRUE
$takesScreenshot
[1] TRUE
$javascriptEnabled
[1] TRUE
$message
[1] "unknown error: Chrome failed to start: exited abnormally\n (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64)"
$hasTouchScreen
[1] TRUE
$platform
[1] "ANY"
$cssSelectorsEnabled
[1] TRUE
$id
[1] "17e6e349-9a67-4423-a817-1798a3e60933"
> remDr$navigate(url)
Selenium message:no such session
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 38 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'akshay-300E4Z-300E5Z-300E7Z', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-64-generic', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64), platform=ANY}]
Session ID: 31de4b0c481e4d0f4fae80ad2920f5c3
Error: Summary: NoSuchDriver
Detail: A session is either terminated or not started
class: org.openqa.selenium.NoSuchSessionException
Further Details: run errorDetails method
selenium server logs at server start :-
$ java -jar -Dwebdriver.chrome.driver=/home/hdpusr/ChromeDriver/chromedriver selenium-server-standalone-3.0.1.jar
19:24:09.727 INFO - Selenium build info: version: '3.0.1', revision: '1969d75'
19:24:09.728 INFO - Launching a standalone Selenium Server
2017-01-24 19:24:09.747:INFO::main: Logging initialized #299ms
19:24:09.808 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
19:24:09.808 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
19:24:09.809 INFO - Driver class not found: com.opera.core.systems.OperaDriver
19:24:09.809 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
Unable to create new instances on this machine.
19:24:09.809 INFO - Driver class not found: com.opera.core.systems.OperaDriver
19:24:09.809 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
19:24:09.810 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX
2017-01-24 19:24:09.853:INFO:osjs.Server:main: jetty-9.2.15.v20160210
2017-01-24 19:24:09.882:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#6d8a00e3{/,null,AVAILABLE}
2017-01-24 19:24:09.900:INFO:osjs.ServerConnector:main: Started ServerConnector#4f933fd1{HTTP/1.1}{0.0.0.0:4444}
2017-01-24 19:24:09.900:INFO:osjs.Server:main: Started #452ms
19:24:09.900 INFO - Selenium Server is up and running
the following is the selenium server logs when i run
remDr$open()
server logs :--
19:24:28.515 INFO - SessionCleaner initialized with insideBrowserTimeout 0 and clientGoneTimeout 1800000 polling every 180000
19:24:28.548 INFO - Executing: [new session: Capabilities [{nativeEvents=true, browserName=chrome, javascriptEnabled=true, version=, platform=ANY}]])
19:24:28.566 INFO - Creating a new session for Capabilities [{nativeEvents=true, browserName=chrome, javascriptEnabled=true, version=, platform=ANY}]
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 20845
Only local connections are allowed.
19:24:28.990 INFO - Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
19:25:29.106 INFO - Detected dialect: OSS
19:25:29.154 INFO - Done: [new session: Capabilities [{nativeEvents=true, browserName=chrome, javascriptEnabled=true, version=, platform=ANY}]]
the following is the selenium server logs when i run
remDr$navigate(url)
server logs :--
20:33:42.918 INFO - Executing: [get: https://www.goodreads.com/book/show/18619684-the-time-traveler-s-wife#other_reviews])
No protocol specified
20:33:42.961 WARN - Exception thrown
org.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'akshay-300E4Z-300E5Z-300E7Z', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-64-generic', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64), platform=ANY}]
Session ID: e19869d41d81d1bbc51432cf08bec577
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
at com.sun.proxy.$Proxy4.get(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.get(EventFiringWebDriver.java:162)
at org.openqa.selenium.remote.server.handler.ChangeUrl.call(ChangeUrl.java:40)
at org.openqa.selenium.remote.server.handler.ChangeUrl.call(ChangeUrl.java:25)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
20:33:42.967 WARN - Exception: no such session
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'akshay-300E4Z-300E5Z-300E7Z', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-64-generic', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64), platform=ANY}]
Session ID: e19869d41d81d1bbc51432cf08bec577
I also tried running selenium server using rsDriver but didn't made any difference, following is the rsDriver result
> rD <- rsDriver(port = 4567L, browser = c("chrome", "firefox", "phantomjs", "internet explorer"), version = "latest", chromever = "latest", geckover = "latest", iedrver = NULL, phantomver = NULL, verbose = TRUE, check = TRUE)
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking geckodriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
[1] "Connecting to remote server"
$webdriver.remote.sessionid
[1] "83941a25-4d50-426f-a006-2f056462f2b0"
$locationContextEnabled
[1] TRUE
$webStorageEnabled
[1] TRUE
$takesScreenshot
[1] TRUE
$javascriptEnabled
[1] TRUE
$message
[1] "unknown error: Chrome failed to start: exited abnormally\n (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64)"
$hasTouchScreen
[1] TRUE
$platform
[1] "ANY"
$cssSelectorsEnabled
[1] TRUE
$id
[1] "83941a25-4d50-426f-a006-2f056462f2b0"
please someone assist me here.
Thanks
There seems to be an issue with chrome/chromedriver/selenium server. You will need verbose logging to check in more detail:
library(wdman)
library(RSelenium)
selServ <- selenium(jvmargs = c("-Dwebdriver.chrome.verboseLogging=true"))
remDr <- remoteDriver(port = 4567L, browserName = "chrome")
remDr$open()
selServ$log()
or if you prefer running seperately in the terminal start a selenium server as follows:
java -Dwebdriver.chrome.verboseLogging=true -Dwebdriver.chrome.driver=/home/hdpusr/ChromeDriver/chromedr‌​‌​iver -jar selenium-server-standalone-3.0.1.jar -port 4444
You can then file an issue with https://bugs.chromium.org/p/chromedriver/issues/list if the problem is not apparent.

RSelenium error when connecting to server using Internet Explorer in windows

I try to use the RSelenium in windows with IE as browser as it seems there are some discrepancies with other browsers, and need some fixing with the newer versions.
I do as previously instructed in SO answers:
library(RSelenium)
startServer()
remDr <- remoteDriver(browser="internet explorer")
remDr$open()
remDr$open()
[1] "Connecting to remote server"
Selenium message:Unable to create new remote session. desired capabilities = Capabilities [{nativeEvents=true, browserName=internet explorer, javascriptEnabled=true, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'CL5065F329EBF2', ip: '130.115.158.36', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_91'
Driver info: driver.version: InternetExplorerDriver
Error: Summary: SessionNotCreatedException
Detail: A new session could not be created.
class: org.openqa.selenium.SessionNotCreatedException
Further Details: run errorDetails method
Also when starting server or checking for servers I receive errors regarding deprecated use of the function.
For example:
startServer()
Warning message:
startServer is deprecated.
Users in future can find the function in file.path(find.package("RSelenium"), "example/serverUtils").
The sourcing/starting of a Selenium Server is a users responsiblity.
Options include manually starting a server see vignette("RSelenium-basics", package = "RSelenium")
and running a docker container see vignette("RSelenium-docker", package = "RSelenium")

org.openqa.selenium.WebDriverException: Permission denied to access property "toString"

I am using Selenium WebDriver to automate a page developed in angular framework. But when I run my tests on FirefoxDriver I am facing the below issue. The same code works perfectly on InternetExplorerDriver.
org.openqa.selenium.WebDriverException: Permission denied to access property "toString"
Command duration or timeout: 685 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'L8WF0N72', ip: '30.142.97.71', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=46.0.1, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: c35d9fb2-7697-4ecd-a7d5-0c8005182065
*** Element info: {Using=id, value=loginusername_txt_id}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:413)
at org.openqa.selenium.By$ById.findElement(By.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:899)
at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:41)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:205)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:201)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:238)
at utilities.WebUtils.waitForElementVisible(WebUtils.java:23)
at testCases.MenuOfResourcesTests.testSetUp(MenuOfResourcesTests.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:178)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
Caused by: org.openqa.selenium.WebDriverException: Permission denied to access property "toString"
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'L8WF0N72', ip: '30.142.97.71', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: unknown
at <anonymous class>.patchEventTargetMethods/obj.addEventListener(https://va10dlvwbs302:9443/eea/app/common/lib/angular2/angular2-polyfills.js:1072)
There has been a lot of back and forth between Angular and WebDriver communities on this defect. The below thread's would give you where the defect is currently residing.
Github Issue Tracker
The last comment on the defect is
Angular 2 is patching EventTarget.prototype, so they are responsible for any bugs caused by their changes.
This is not a Selenium issue, closing the bug.
So, i don't think there is a solution yet to this problem, but a few things that you can cross check is if you are using the latest selenium client library version and if the ff version you are using is as mentioned as supported by selenium folks
Selenium WebDriver Supported Browsers and Versions

Webdriver is not cicking a link in a inbox

My web application has an inbox, just like gmail inbox, my objective is to click on a mail item and verify the content in it.
The Outer HTML of my mail item in the Inbox is as follows
Complete Registration Request- My WebSite
i wrote a java code as
driver.findElement(By.partialLinkText("Complete Registration Request- My WebSite")).click();
(ps:i also tried with linkText).
another approach was
#FindBy(how=How.LINK_TEXT,using="link=Complete Registration Request- My WebSite")
#CacheLookup
private WebElement regMailLink;
inside method
regMailLink.click();
in both cases the output was as follows .
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"partial link text","selector":"Complete Registration Request- My WebSite"}
Command duration or timeout: 31.44 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 20:21:18'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_39'
Session ID: 2baf4e73-c070-4046-8723-b4ae430a827d
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=16.0, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:533)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:302)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByPartialLinkText(RemoteWebDriver.java:347)
at org.openqa.selenium.By$ByPartialLinkText.findElement(By.java:265)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:294)
at stabilix.org.hc.MailCode.testValidateEmail(MailCode.java:74)
at stabilix.org.hc.createUserPageTest.NewUsrStage1(createUserPageTest.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:128)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1203)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1128)
at org.testng.TestNG.run(TestNG.java:1036)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to locate element: {"method":"partial link text","selector":"Complete Registration Request- My WebSite"}
Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 20:21:18'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_39'
Driver info: driver.version: unknown
at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/moshe/LOCALS~1/Temp/anonymous7889540798209195994webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js:8251)
at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/moshe/LOCALS~1/Temp/anonymous7889540798209195994webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js:382)
---
---
Well, ok. This is still more thought than advice:
According your comment, that application has frames. And I think that this link will be inside frame. And this frame should have its name:
<frame name="main"> //my guess
//...
Complete Registration Request- My WebSite
//...
</frame>
So, first thing you need to do to switch driver to this frame
driver.switchTo.frame("main");
And then you can perform the search
driver.findElement(By.partialLinkText("Complete Registration Request- My WebSite")).click();
NOTE The frame name is my own guess, so please do not copypaste my code. Use it as a guide ;)
Here Actually we can try with the given below CSS Selector
css=a[href*='INBOX']
Please Let me know with this CSS the script is working or NOT.

Resources