it is defined properly
if i use it like this "safeSendKeys(By.xpath("//*[@id='content-container']/div[4]/div[2]/form/input"));" safeSendKeys is not underlined. Here I leave both lines uncommented so you can see that it is defined properly |
Administrator
|
ah, see I had mentioned earlier that I had modified my response.
Your safeSendKeys should be (notice that it takes two arguments) - public void safeSendKeys(By locator, String testdata) { int i=0 while (i<30) { try { driver.findElement(locator).sendKeys(testdata) break; }catch(Exception e) { e.printStackTrace(); i=i+1; Thread.sleep(1000); } } } and call it as - sendKeys(By.xpath("//*[@id='content-container']/div[4]/div[2]/form/input") , "C:\\Users\\Public\\Pictures\\Sample Pictures\\Jellyfish.jpg");
~ seleniumtests.com
|
thanks now its ok but it is still not working it just times out
|
Administrator
|
Can you post full stack trace of error and and line throwing error in your code?
~ seleniumtests.com
|
java.lang.AssertionError: timeout
at org.junit.Assert.fail(Assert.java:93) at chrome.SubmitIdea.testSubmitIdea(SubmitIdea.java:58) 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) driver.findElement(By.linkText("Idee Einreichen")).click(); for (int second = 0;; second++) { if (second >= 60) fail("timeout"); try { if (isElementPresent(By.xpath("//span[text()='close']"))) break; } catch (Exception e) {} Thread.sleep(1000); } driver.findElement(By.xpath("//span[text()='close']")).click(); // driver.findElement(By.xpath("//*[@id='content-container']/div[4]/div[2]/form/input")).sendKeys("C:\\Users\\Public\\Pictures\\Sample Pictures\\Jellyfish.jpg"); safeSendKeys(By.xpath("//*[@id='content-container']/div[4]/div[2]/form/input") , "C:\\Users\\Public\\Pictures\\Sample Pictures\\Jellyfish.jpg"); for (int second = 0;; second++) { if (second >= 60) fail("timeout"); //this line trows the error try { if (isElementPresent(By.xpath("//span[text()='Save']"))) break; } catch (Exception e) {} Thread.sleep(1000); } driver.findElement(By.xpath("//span[text()='Save']")).click(); Thread.sleep(3000); driver.findElement(By.name("title")).clear(); driver.findElement(By.name("title")).sendKeys("idea testing"); |
Administrator
|
Looks like this element is not found after upload and eventually you run in to time out error -
By.xpath("//span[text()='Save']") Can you manually check if this element appears after you do upload operation in chrome?
~ seleniumtests.com
|
No it does not appear. Normally when I upload the picture a popup shows up and there you select which part of the picture you want to save as main picture for your idea. But because the upload is not working it does not appear and it fails to find the save button.
|
Free forum by Nabble | Edit this page |