I had written a script in selenium webdriver which uses click() to click on a button which is a "dojo" element.
Previously it was working fine but its not working now, i have tried all the possible ways to make it work (using javascipt, waiting for element to be present, checking enabled and disabled options etc etc) but nothing seems to work.
I would really appreciate if anybody could help me out with this. thanks in advance. i am attaching the script and html code for ur reference.
public void Search_Project_Test(String Project_name,String Os_type,String Start_rel,String End_rel) throws InterruptedException, IOException
{
this.Software_type.click();
this.select_os_type(Os_type);
this.search_proj.sendKeys(Project_name);
com.wait_till_pageload();
SORA_Constants.driver.findElement(By.xpath("//button[#id='submit_project_search']")).click();
Thread.sleep(5000);
Try this ! And also check that element is visible on the page
SORA_Constants.driver.findElement(By.id("submit_project_search")).click();
IT worked finally, all I did is upgraded the FireFox version. i was using 23.0 and later switched to 26.0 which resolved the problem. i never knew if selenium had such kind of issues with different versions of firefox. Hope if anyone faces similiar kind of situation later, then this could b helpful. :)
Try this:
SORA_Constants.driver.findElement(By.xpath("//button[#id='submit_project_search']")).SendKeys("\n");
or:
SORA_Constants.driver.findElement(By.xpath("//button[#id='submit_project_search']")).SendKeys(Keys.Enter);
Related
I am using Karate robot for clicking a button using image.
Below is my code:
robot { app: '^Chrome', highlight: true }
robot.input('OracleDriver')
delay(2000)
robot.click('delete.png')
Sometimes I am able to click delete button for delete.png but other times I am not.
So facing this issue intermittently.
Yes, finding by image is indeed not very reliable and should be only used as a backup when normal windows locators don't work.
I have only the following suggestions:
find a windows locator that works. note that you can navigate from a known locator using someElement.parent.firstChild etc: https://github.com/intuit/karate/tree/master/karate-robot#element-api
try to standardize the resolution that works best
see if using OCR works better
contribute code to Karate to make this better
look for another solution
I tried clicking delete button by using it's class and it is very reliable, below is my code
waitFor('.icons8-delete-blue').click()
I also followed #Peter's suggestion (someElement.parent.firstChild) and it worked for me!, below is the code
waitFor('.modal-footer').children[0].click()
Thanks #Peter for the suggestion
I'm using Eclipse/Java and interfacing with the Selenium chrome webdriver.
The code I'm executing is
Sting sValue = item.getAttribute("innerHTML");
If I am stepping over this code it works fine.
Otherwise, if I just run the code. It throws a NUllPointerException.
What gives? Any ideas?
Thanks!
It's possible the page doesn't have enough time to load when you run straight through, but when you step with the debugger it's just enough extra time for the page to finish loading and avoid the NullPointerException. Try adding a wait, as described in the accepted answer for this question: Getting Selenium to pause for X seconds.
This is not a real answer, it's just a total hack! I have to get some things done so I'll investigate predicates and WebDriverWaits later.
I was creating a list of webelements:
List wElements = getElements()
Then I was trying to get the innerHTML from each webelement in the list.
It works fine in debug mode, but when I execute the code it fails to gather the information IN SOME OF THE ELEMENTS in the collection. So what I did was retrieve the same list a second time.
List wElementsB = getElements()
Then I retrieved the innerHTML out of the wELementsB. Works fine.
I tried sleeping and telling the webdriver to wait. but those failed as well.
Thanks Guys!
Hi I am trying to run my selenium webdriver on IE9.
WebDriver version : 2.32.0
IE:9
IEDriverServer_win32:2.32.3
windows7
Below is my code:
File IEDriver=new File(System.getProperty("user.dir")+File.separator+"BrowserDrivers"+File.separator+"IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", IEDriver.getAbsolutePath());
DesiredCapabilities cap=DesiredCapabilities.internetExplorer();
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver=new InternetExplorerDriver(cap);
driver.get("http://in00616:8421/GS");
Thread.sleep(3000);
//driver.findElement(By.id("j_username")).sendKeys("admin");
//driver.findElement(By.id("j_password")).sendKeys("admin");
driver.findElement(By.xpath(".//input[#id='j_username']")).sendKeys("admin");
driver.findElement(By.xpath(".//input[#id='j_password']")).sendKeys("admin");
driver.findElement(By.id("login")).submit();
Thread.sleep(2000);
driver.findElement(By.xpath(".//button[text()='Securities']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath(".//span[text()='Issue']")).click();
Thread.sleep(2000);
driver.findElement(By.id("tabSecurities_Issue_Request_for_Issues")).click();
Above code logs in to my site but then when I try to click on Securities button I am not able to do it. Securities button starts flickering and then I am notified that unable to find the element.
Exception in thread "main" org.openqa.selenium.NoSuchElementException:
Unable to find element with xpath == .//span[text()='Issue Type']
(WARNING: The server did not provide any stacktrace information) –
Same code works fine in FireFox.
Please help as i am suppose to test my UI on InternetExplorer.
I think it is the version compatibility issue.
Can anyone suggest the compatible version set for IEDriverServer, Selenium WebDriver and IE which is in working condition.
As this SO answer points out, IE does not have native XPath support. Instead, Selenium WebDriver uses an old third party xpath library when IE is being used. Firefox has integrated support for XPath, which is why your selectors work fine in that browser.
I would highly recommend you update your selectors to instead use CSS selectors. They are supported across all browser, are easier to read, understand, and pick up, and they are pretty fast.
You can learn more about how to use CSS selectors from some different tuturials here, here, and here, and a CSS selectors cheatsheet.
Also, whenever possible, please try to not select an element by the text it contains. If you can select an element by its ID, class, other attribute, or even through the DOM chain (i.e. "div.1 > div.2 > span.a > a.b"), is better than trying to select an element by text.
Webdriver has difficulty with IE using locators. It seems like Murnal has difficulty using CSS locator. My advice would be you HAVE to use other locators if one doesnt work. This issue comes again and again while using non firefox browser. In the meantime an easier way to come up with alternate locator is use Firefox selenium IDE, there in the boxes where you type command you will see it gives alternate locator as well. Copy that and try plugging tha in your webdriver's findelement script.
Hi all i have found out that it was the issue of Selenium Webdriver 2.32 with IEDriver_Server2_32. After trying out permutation & Combination with latest available webdriver versions and IEDriver_Server, i have found out suitable stable configuration to work on IE9 below is the stable configuration : Webdriver : 2.33.0 IEDriver_Server : 2.33.0. There is still small issue but i am trying to look for workaround. Issue : In IE if some control's tooltip overlaps other control than IE is not able to find out that control. i guess this issue is with IEs working. IE uses nativeEvents to perform operation hence it is not able to locate that control. In FF it is able to find out that control and it is working fine. Thanks everyone.
We're using JBehave Web to drive our selenium test suite for a new project and really like the Etsy.com example available on JBehave, especially the Java/Spring maven archetype as this fits in with our architecture.
The biggest problem so far has been documentation, which is why I'm posting here in the hopes that I can get some help from others in a similar situation.
It looks like JBehave Web only provides a "FirefoxWebDriverProvider" class and no corresponding one for Chrome. Has anyone else run into this problem? Have you written your own ChromeDriverProvider?
Also, we need to change the size of the browser that comes up by default and I can't seem to find a way of doing that during the bootstrapping of the test run.
We're using the Maven archetype: jbehave-web-selenium-java-spring-archetype which uses the jbehave-maven-plugin and the "run-stories-with-annotated-embedder" goal so we're using the "Annotated" method of extending the InjectableEmbedder.
If anyone can provide some guidance, I'd really appreciate it, even if just pointers to more examples.
How To Resize Window
webDriverProvider.get().manage().window().setSize(new Dimension(width, height));
You can easily find code like this by navigating through the code. If you are using Eclipse, Open Declaration and Quick Type Hierarchy options are everything you need.
How to Use Chrome Driver
You can use TypeWebDriverProvider or PropertyWebDriverProvider. For instance:
new TypeWebDriverProvider(ChromeDriver.class);
This should work:
driver.manage().window().setSize(new Dimension(800, 621));
What jokka said is correct, justr a side note: Before resizing window, I always put it to top left corner, so I know that WebDriver can "see" everything:
driver.get().manage().window().setPosition(new Point(0, 0));
Obviously, the driver above is assumed healthy instance of WebDriverProvider
We ended up finding this Chrome Driver and it's been working great. It can take a parameter when it is bootstrapped to start in maximized mode and also exposes the capability to add extensions when it starts up.
driver.Manage().Window.Size = new Size(x, y);
This works fine for me. The x and y are in a feature file.
Try this:
This is working fine for me.
Capybara.current_session.driver.browser.manage.window.resize_to(1800, 1000)
I'm trying to make a click-and-drag event work using Selenium Webdriver (2.15). It works fine when using FF, but in Chrome it does not. In Chrome, it appears to have no effect. Here's what my code looks like:
Actions builder = new Actions(GuiOps.driver);
builder.MoveToElement(fromElem).ClickAndHold().MoveToElement(toElem).Release().Build().Perform();
Has anyone gotten ClickAndHold() to work successfully using Chrome?
Turns out this is a known issue. There's a workaround posted at http://code.google.com/p/chromium/issues/detail?id=92312 . Basically, you add a MoveByOffset(1,1) immediately after that ClickAndHold() call and it works.
First post/comment here. :)
Well, it worked for me. All you need to give is a bit of a pause after the "moveByOffset(1, 1)". It seems that the script is executing faster than it should. Here's a piece of code that worked for me:
"actions.clickAndHold(we).moveByOffset(1, 1).pause(1000).perform();". Hope it helps.