Hi i wan set a test of a text area using gecko browser
that is the html of my page
<textarea id="noteField" data-nemo="note-field" class="textArea_gebdo3" style="height: 44px;">texthere</textarea>
as you can see the vaule is not setted in value="text" so i can use usually code for get element and set the vale some idea please ?
This post have a solution in Java with SendKey():
How to set text into TextArea with Selenium Webdriver?
It seems to be close to your problem but it's not the best solution.
Related
I'm working with Selenium Webdriver on Eclipse, and I want to access the hyperlink for forget password:
<p class="mt15 text-center fs-12 forgot-password-links">Forgot Password?</p>
I've tried using linkText, partialLinkTest as well as WebElement. Nothing seems to work so far. Any suggestions? Thanks in advance!
According to the HTML you provided that element can be located with the following XPath:
//a[#href='forgotpassword.htm']
or if you prefer cssSelector
a[href='forgotpassword.htm']
I want to store href url from an image but when i try it show error
This is the code
<img src="//user/banners/16/08/1614708.gif" alt="AAA" data-tip="BBB" currentitem="false" class="" width="468" height="60">
I want to store mysite.com
I already tried storeattribute with xpath and #href but show error (not available work for text link only)
Usually i use ui vision or katalon recorder but i never find a good solution at moment.
I need only xpath
Try this one out to get the parent a tag of the img src.
print(driver.find_element_by_xpath("img[src='//user/banners/16/08/1614708.gif']//parent::a").get_attribute('href'))
I am trying to find the text box in the image below
My xpath using chrome is
div[#id='element.problem.short_description']
div[#class='col-xs-10 col-md-9 col-lg-8 form-field input_controls']
still it fails on selenium.
the code is here on the webpage. I Couldn't copy it for some reason, so attaching a screenshot of it
Because you're not looking at the text field.
All you need is //input[#id='problem.short_description']
I am automating a webpage using selenium.
My Problem is selenium is unable to type the text in hidden fields. I used
selenium.type("xpath of hidden field","some text");
But it is not working. It's not giving any error, but not typing anything into that hidden field.
Example: Typing text into Gmail's body field(in composing mail). this is the exact example of my issue
This is Rad Editor. So code is something like this(here the text is saving inside iframe-->html-->body)
<iframe id="iframe1">
<html>
<body> This is some text </body>
</html>
</iframe>
There's just no way you'll force Selenium to type into a hidden element.
Would this work? It uses Javascript's document.evaluate() to find the element by XPath and then types directly into the found element's value.
selenium.GetEval(
"var xpath = '//XPath/to/your/element';" +
"var text = 'some text to input into the element'" +
"var elem = window.document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);" +
"elem.singleNodeValue.value = text;" );
If not, try to run it in FireBug and post the result (or error) here.
The next thing to try would be to try to make the element visible...
EDIT - the above won't work
You have like all the problems in one place :)
An iframe. You must select it before trying to interact with anything inside.
If the iframe loads anything from a different domain, then the Same origin policy for JavaScript kicks in. And since Selenium RC is written in pure JavaScript, it can't do anything. You can either switch to WebDriver which doesn't suffer from this, or try to reopen the browser on the internal address of the iframe. Might not work, though.
The body tag in the iframe is contenteditable which is a problem solved by WebDriver. Selenium RC should be able to type() into it just as well.
An invisible textarea. That's your last problem. If you really needed to write into it (there's the editable body), you you'll have to use JavaScript, because Selenium RC refuses to work with invisible elements.
As this is a RadEditor the text is going inside iframe-->html-->body (This is in my case. It may be different for different Editors)
So in order to write text, first we need to select the iframe. And then we have to enter the text. This can be done as
selenium.SelectFrame("xpath_of_iframe"); //Selecting the iframe
selenium.Type("//html/body","Thank you"); //Inserting the text
So now the code changes to
<iframe id="iframe1">
<html>
<body> Thank you </body>
</html>
</iframe>
Thank you.
I'm working on dealing with a file-chooser dialog using Selenium 2 - WebDriver. Believe it or not, my problem is NOT dealing with the OS-native file-chooser. That part I can handle!
The problem is getting Selenium to properly click on the "Choose File" button. Since the original source html is simply <input type='file'>, the browser determines how to render it as a field and a button. As a result, the placement and naming of the button changes depending on browser. I've got it working in Chrome, but only because Chrome places the button on the leftmost alignment and Selenium happens to click there by default.
Any ideas? It's not clear to me if an input of this type is truly navigable from within the DOM anyway...
The proper way to upload a file on any OS is to
Find the <input type='file'> element. You need not to worry about different implementations and exact positioning. Just find the element for example by xpath //input[#type='file']
sendKeys() or type() (or whatever method writes text into elements in your language) the path to file to that input element.
Sample Java code:
// find the input element
WebElement elem = driver.findElement(By.xpath("//input[#type='file']"));
// 'type' the file location to it as it were a usual <input type='text' /> element
elem.sendKeys("C://path/To/File.jpg");
This works on every OS and browser in WebDriver.
Have exactly the same situation with element <input type='file'>. In my case it is created using ExtJS.
I don't know whether you have solved this question or not but let me provide my solution.
JavascriptExecutor executor = (JavascriptExecutor)getDriver();
executor.executeScript("arguments[0].click();", element);
Neither sendKeys() or type() nor using ActionBuilder was helpful for me. The only JavascriptExecutor works like a charm.
I tested with the following element:
<INPUT style="WIDTH: 550px; background-color:yellow" type="file">
Results:
IE: doubleclick on any area of the element, the "Choose File" dialogue would occur;
Firefox: click on any area of the element, the "Choose File" dialogue would occur.