Перейти к содержимому

Фотография

Ошибка Unable to locate element


  • Авторизуйтесь для ответа в теме
Сообщений в теме: 2

#1 irko

irko

    Новый участник

  • Members
  • Pip
  • 40 сообщений
  • ФИО:S Irina

Отправлено 14 мая 2015 - 08:06

Добрый день! Подскажите, пожалуйста, почему может быть следующая ошибка:

 

rg.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"link text","selector":"cheese"}
Command duration or timeout: 30.22 seconds
For documentation on this error, please visit: http://seleniumhq.or...ch_element.html
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'xx', ip: '192.168.149.227', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_79'
*** Element info: {Using=link text, value=cheese}
Session ID: 1fe10d4f-5f8d-4e6e-bbae-fb1b2d7d582e
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=37.0.2}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByLinkText(RemoteWebDriver.java:401)
at org.openqa.selenium.By$ByLinkText.findElement(By.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at com.eviltester.webdriver.CatalogPage.catalogeSearchForm(CatalogPage.java:62)
at com.eviltester.webdriver.ComTest.test1(ComTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"link text","selector":"cheese"}
For documentation on this error, please visit: http://seleniumhq.or...ch_element.html
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'ISAVELEVA', ip: '192.168.149.227', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_79'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/ISAVEL~1/AppData/Local/Temp/anonymous6691705699751790639webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10271)
at <anonymous class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/Users/ISAVEL~1/AppData/Local/Temp/anonymous6691705699751790639webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:603)
 
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
 
Process finished with exit code -1
 
Если код искомого элемента выглядит так:
 
<div>
 
    <div class="catalog-icon"></div>
    <div class="catalog-details" style="display: table">
        <div>
            <b>
 
                Название модуля 1
 
            </b>
        </div>
        <div></div>
    </div>
 
</div>
 
И соответственно пишу:
WebElement moduleCardName  = driver.findElement(By.linkText("cheese"));
moduleCardName.getText();
 
Ни один элемент не могу найти таким образом:((

  • 0

#2 BabyRoot

BabyRoot

    Специалист

  • Members
  • PipPipPipPipPip
  • 833 сообщений


Отправлено 14 мая 2015 - 08:11

By.linkText заменить на cssSelector  - ".catalog-details b"

конечно, если такой элемент на странице один.


  • 1

#3 irko

irko

    Новый участник

  • Members
  • Pip
  • 40 сообщений
  • ФИО:S Irina

Отправлено 14 мая 2015 - 08:34

By.linkText заменить на cssSelector  - ".catalog-details b"

конечно, если такой элемент на странице один.

 спасибо большое! получилось!


  • 0


Количество пользователей, читающих эту тему: 0

0 пользователей, 0 гостей, 0 анонимных