Selenium IEDriverServer not sending keys when using RemoteWebDriver - java

So I have a test case set up which works perfectly fine using Testng and running the IEDriverServer locally. But when running the test case using Grid 2 the following command doesn't appear to work:
driver.findElement(By.xpath("(//input[#type='text'])[3]")).sendKeys(logNum);
There are no errors and the output from the node states that it had completed, but no text appears in the edit box. I checked running the test through a debugger and the "logNum" variable does have a value
I can not fathom why its not working
I am using selenium-server-standalone-2.44.0.jar running the Hub and Node on the same machine

I have resolved this by removing
capability.setCapability("nativeEvents", false);
from my initiation of the driver.

I recently came across the same problem. I used JavascriptExecutor to set the value of the element.
public static void useJSSendKeys(String value,WebElement element){
JavascriptExecutor myExecutor = ((JavascriptExecutor) driver);
myExecutor.executeScript("arguments[0].value='"+value+"';", element);
}

good to know that your issue is resolved on making capability.setCapability("nativeEvents", false); but it may create problem when you try to perform native events. so if you not tried, please try performing click before sendkeys. it helps me some times and also providing Thread.sleep(3000) in java also helps me in some situations. please try these if not.
Thank You,
Murali

Related

Need to wait for finding specific element on loading webpage - selenium 3.141.5 and java 8

Using selenium 3.141.5 (Latest) and java 8. Now I have a situation where I need to wait for particular element on webpage to get loaded before I execute next line. I am trying to use ExpectedConditions java class but unable to import this. In the javadoc of selenium I can find ExpectedConditions and ExpectedCondition. [PSB]
static ExpectedCondition<WebElement> presenceOfElementLocated(By locator)
An expectation for checking that an element is present on the DOM of a page.
I am not using any maven or any other tool. it is just eclipse, java and selenium.
Image from my local eclipse
Please help for the same. I just want to wait for particular element to get loaded before I execute my next line of code with latest selenium and java. Thanks in advance! :) I hope I have tried to explain well if not then sorry
I'm using ExpectedConditions:
// modified wait method
public WebDriverWait wait_sec(WebDriver driver, int sec) {return new WebDriverWait(driver, sec);}
// example of usage one of ExpectedConditions
driver.get(url_portal);
WebElement fld_pwd = wait_sec(driver, 60).until(ExpectedConditions.elementToBeClickable(By.name("password")));
fld_pwd.click();
fld_pwd.sendKeys(sec_var.getPwd());
// example of negative usage
wait_sec(driver, 300).until(ExpectedConditions.not(ExpectedConditions.urlContains("#")));
Exploring ExpectedConditions was trully essential for my tests.
I switched to selenium 3.11 and now everything is working as expected!. There I can use ExpectedConditions
Thanks

Switching between tabs using webdriver in chrome

Am Opening a page performing some actions on that and i am using this piece of code to open another link in the next tab
String url = "https://qa.logfireapps.com/lgf_700_qa_rf";
String args1 = String.format("window.open('%s', '%s');", url, "new");
((JavascriptExecutor) driver).executeScript(args1);
Then i need to switch between this two tabs.
I used driver.switchTo.window(parentWin);
I also used this code
List windowHandles1 = new ArrayList(driver.getWindowHandles());
driver.switchTo().window(windowHandles1.get(1));
Both of the cases did not work for me,but still the web driver code is running successfully without any errors even its not switching to first window.
I need to switch to the first tab,but all the actions are going on in the first tab but still in UI am seeing the second tab opened,It is not switching to the first tab but my whole webdriver code gets passed.
It is observed that switching problem happens only with this two sites
1) https://qa.logfireapps.com/lgf_700_qa/index/
2) https://qa.logfireapps.com/lgf_700_qa_rf
This was my solution to this using python. sorry no java example
def switch_to_new_window(driver, window):
driver.switch_to_window(driver.window_handles[window])

java selenium - hidden input value

First Stack post, so don't be harsh if I get it wrong.
Im using selenium and java for some automated testing. All was going well until I tried to set the value of a hidden input.
When using 'type' in the Firefox IDE, it works a treat, but when I use the line below, it doesn't play at all. It just fails.
// This line doesnt like to run because its hidden
selenium.type("name=startDate_submit", "2015-09-25");
Can anyone point me in the right direction.
Many Thanks.
Edit:
WebDriver driver = new ChromeDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("$([name=startDate_submit]).attr('type', 'text');");
Thread.sleep(3000);
// This line doesnt like to run because its hidden
selenium.type("name=startDate_submit", "2015-09-25");
Should this be the way I do this? I just cannot get it working.
just try with this command,
driver.findElement(By.xpath("path")).sendKeys("value");
but make sure you have clicked that path before providing input value. come back if you still have any problem.
Try with available javascript commads like document.getElementById, then set the value.

WebDriver : SendKeys(Integer) NOT working in Firefox 29

I am using Firefox 29 and WebDriver java 2.41.0 bindings to automate test scenarios. Have one scenario to input an integer to a input-box which was working FINE with Firefox 28 and now failing with v29 i.e latest FF version. The code I wrote for the same is:
int inputString = 123456;
driver.FindElement(By.Id("tinymce")).SendKeys(inputString);
Please help me getting through of this.
This will be the result of this issue:
https://code.google.com/p/selenium/issues/detail?id=7291
Fixed by this revision in the Selenium code:
https://code.google.com/p/selenium/source/detail?r=afde40cbbf5c
Quick test below worked for me. I understand JS is not the right way to do browser simulation, one should always FIRST use webdriver methods since they use browsers native api, but thought it would unblock you while the bug is fixed in selenium
DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
desiredCapabilities.setCapability(CapabilityType.HAS_NATIVE_EVENTS,true);
WebDriver driver = new FirefoxDriver(desiredCapabilities);
driver.get("http://yizeng.me/2014/01/31/test-wysiwyg-editors-using-selenium-webdriver/");
WebElement frame = driver.findElement(By.id("tinymce-editor_ifr"));
driver.switchTo().frame(frame);
WebElement body = driver.findElement(By.id("tinymce"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].innerHTML = '<h1>Heading</h1>Hello There'",body);
Can you check following points
Can you make sure there are no application changes, I mean the locator is returning single node element.
Can you also post the exception that you are getting. To troubleshoot this problem, need these details.
One thing I do before sending a value to a box is to clear it, also, the value I send is always a string, the parsing should be done by the page/code as you need to validate what the user has entered.
But I do agree with skv, we need to see the actual error being thrown.

Selenium HtmlUnit freeze randomly loading a web page

im having a problem with HtmlUnitDriver using Selenium.
Im using the Selenium 2.5 version.
The test is so simply and usualy it works correctly but sometimes the driver just stop and wait endlessly for a page to load.
my code is something like this:
initialization...
private WebDriver driver;
driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);((HtmlUnitDriver) driver).setJavascriptEnabled(true);
//driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS);
driver.manage().timeouts().setScriptTimeout(0, TimeUnit.MILLISECONDS);
and then a lot of blocks like this one:
new Actions(driver).moveToElement(driver.findElement(By.linkText("Someting"))).perform();
driver.findElement(By.linkText("something else")).click();
driver.findElement(By.name("something")).sendKeys("8");
driver.findElement(By.xpath("//img[#title='something']")).click();
after each clic() it loads a new page.
I usualy end the whole test correctly and i have try catched all the blocks so the web is not the problem.
The webdriver is ignoring the timeouts(i try a lot of diferent timeouts and the problem persists) and i cant stop the driver from another threads invoquing "quit()" or "close()"
I search everywhere but i cant found a solution.
¿Anyone can help me?
Thanks in advance.
I solve it, i post my solution if anyone have the same problem.
Im pressing esc from other thread (the main is busy waiting...)
((HtmlUnitDriver) test.getDriver()).getKeyboard().pressKey(Keys.ESCAPE);
and then i kill the browser and restart the test
test.getDriver().quit(); restart();//create a new test instance
I've faced this behaviour before.
I would first update to 2.9 and try again
Then, I would check the pages I'm hitting, because if they have frames or iframes they get downloaded too and if you don't control their content anything could happen
Take a look at this link because it might have the solution you're looking for.
Hope this helps.

Categories