Cannot Input Text into HTML input element using Robot Framework - selenium

I have HTML which looks like this:
<input type="text" name="USERNAME.DUMMY.DUMMY.1" value="" id="USERNAME.DUMMY.DUMMY" class="username" size="25" autocomplete="Off">
I am trying to insert text to this input element after loading it. Her is my Robot script:
Open Browser ${url} ${browser}
Sleep ${wait}
Input Text id=USERNAME.DUMMY.DUMMY ${text}
But it is never able to find the ID. I have tried the same with class and name attributes but none of them work. This element is not under an iFrame.
Any help would be appreciated !

Can you try
input text //*[#id="USERNAME.DUMMY.DUMMY"]

Related

Upload file using selenium vba

I am using selenium vba and on the webpage there is an element that is supposed to enable me to upload a file. Here's the html for that element
<input type="file" name="attachments" id="attachments" accept=".pdf" maxlength="20" class="inputTextBox2">
I tried both methods to click on the element but the element doesn't respond at all
bot.FindElementById("attachments").Click
and
bot.ExecuteScript "arguments[0].click();", .FindElementById("attachments")
but both methods don't work and the element doesn't respond
Solved as I discovered that the input is a textbox so I used SendKeys to send the path
.FindElementByCss(".inputTextBox2").SendKeys THEFILEPATH

Can anyboby help find me xpath for below ? i tried with //input[#class='new-todo ng-pristine ng-valid ng-touched'] but its not able to find it

https://todomvc.com/examples/angular2/ this is the website. and I'm trying to locate text box.
I tried with Xpath driver.findElement(By.xpath("//input[#class='new-todo ng-pristine ng-valid ng-touched']")).sendKeys("Go to GYM");
Also with driver.findElement(By.className("new-todo ng-pristine ng-valid ng-touched")).sendKeys("Blah");
But its still not able to locate element , can someone please help
//input xpath is enough
or //input[contains(#class,'new-todo')] xpath
or new-todo by class name
or .new-todo css selector
Don't forget to set some delay before accessing the element to let the page and the element completely loaded.

Xpath not working as expected while running the test

I am trying to automate the browser, while I try to locate the element via xpath in browser in static mode it is able to highlight the element where as when I run the script it comes back with an error that it is unable to find the element.
xpath I have written:
driver.findElement(By.xpath("//input[#value='soa_b_pbtv_l0_trnkni']/following-sibling::td[1]/child::select[#name='jobaction']")));
Here is the HTML:
<form name="f2" onsubmit="return verify();" action="/ATS/cgi-bin/barcap_jobaction.pl" method="post">
<>
<input name="jobname" type="hidden" value="soa_b_pbtv_l0_trnkni"/>
<input name="jobinstance" type="hidden" value="D03"/>
<input name="jobproceed" type="hidden" value="web"/>
<td style="background-color: #ffffff;">
<select name="jobaction">
if you're trying to select the select, jobaction then try this:
use css selector for the select select[name='jobaction']
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("form[name='f2']")));
List<WebElement> eleList = driver.findElements(By.cssSelector("form[name='f2']")));
for(WebElement element: eleList) {
if(element.findElement(By.cssSelector("input[name='jobname']")).getText().equalsIgnoringCase("expectedValue")) {
WebElement element = element.findElement(By.cssSelector("select[name='jobaction']"));
}
}
The INPUT is hidden so it won't be found using typical Selenium means. Selenium was designed to only interact with elements that a user can see and interact with. You are able to locate it in the browser because you are using JS or JQuery and they are not designed to ignore hidden elements. One way to get around this is to use JavascriptExecutor... it basically allows you to run JS in Selenium and find hidden elements. Since it sounds like you already have successful locators, I would suggest you look up some tutorials on JSE and you should be set.
If you run into a new issue while using JSE, come back and post a new question and we can try to help you.

I want to call the element that contains "xyz" from vb.net with webbrowser

I have html like this:
<input tabindex="0" id="x-widget-2-input" value="xyz" style="width:142px;" class="GP34Q33JX GP34Q33EX" type="text">
I want to call the element that contains "xyz" from vb.net with webbrowser, anyone can help?

How should I approach the html placeholder attribute scenario automation with webdriver

Hi I need to automate a sceanrio where a text input field is there, where a text -
"type here" is displayed.
<input class="textbox" type="text" value="" placeholder="type here" name="q">
I need to verify
1) Text is displayed - "type here"
2) When focus is moved to this text field, the text input field does not display -
"type here"
You can test whether the browser supports the placeholder attribute for <input> elements via a simple JavaScript. This is an indirect test, but as far as I know, you can't test for the placeholder text via Selenium. But it should be absolutely sufficient:
function supportsInputPlaceholder() {
var input = document.createElement('input');
return 'placeholder' in input;
}
(taken from http://diveinto.html5doctor.com/detect.html#input-placeholder)
Therefore:
// only if your driver supports JS
JavascriptExecutor js = (JavascriptExecutor)driver;
String placeholderTest = "return 'placeholder' in document.createElement('input')";
assertTrue(js.executeScript(placeholderTest));