Selenium HtmlUnitDriver not clicking on button [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to click on the button:
<input type="submit" value="Stock!" class="button" tabindex="5" />
Here is my code:
WebElement stock = driver.findElement(By.xpath("//*[#id=\"stock\"]/table/tbody/tr[4]/td/input[5]"));
stock.click();
The program runs without throwing any errors, but the button is not being clicked, and the program is not completing its task.

Try using SendKeys instead of Click. Although it looks strange, it has worked for me in many times.
stock.sendKeys(Keys.ENTER);
Or you can do this very simply as shown below. This will automatically submit the values in the particular form where the element is present. Life made easy.
stock.submit();
Not necessarirly you should use the input (type=submit) for the submit() action. You can use any other element in the html form.

Remove the \" and replace it with '. However, you don't actually have an id attribute so that isn't going to work.
Try:
"//input[#tabindex='5']"
If the tab index is actually set there should only be one that has 5 in there. If there is more than one for some reason you can use the full xpath, but it is really not a good idea to utilize the entire xpath with numbered indexes. If anything changes these might break easily.

You can use cssselector, which looks very clean to read.
WebElement stock = driver.findElement(By.CssSelector("input[value = 'Stock!']")).Click();

Try
driver.findElement(By.className("button")).click();

Related

Is it possible to put a button in a NatTable? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
enter image description here
Is it possible to put a button in the table like the attached image?
NatTable is a custom painted table control. Putting real buttons in the table is possible, but actually does not really make sense and could even lead to resource issues in larger tables.
You can actually render anything if you have a corresponding painter. And for a button you of course also need the action binding. NatTable has the ButtonCellPainter to render a cell as a button. But actually the implementation to mimik the button press is a bit outdated IMHO. The corresponding example should give you an idea what you can do and how to do it.
https://git.eclipse.org/c/nattable/org.eclipse.nebula.widgets.nattable.git/tree/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_102_Configuration/Rendering_cells_as_a_link_and_button.java

Drop down box value changes [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I started creating an automation framework for my current company. now I’m having a problem with a form that has a JS modal appearing top part of the form attaches to it. that JS form comes every time if I change the default value of the form (Changes Detected: save button, dismissed button). the issue is there is a drop-down box and the default value is set to empty. after I change that to a value (eg: house) that JS modal comes that I have made a change to the form and put the value of the drop-down box to that default empty value. this happens in the run time. if I put a thread.sleep for 3 seconds that solves the issue. but I need a more reliable solution. are there any other options that I can use for this issue?
All I can think of now is to call that first function, Wait for success
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.javaScriptThrowsNoExceptions("putValue()"));
May be a little bit

java Selenium Chrome - click button [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
Good afternoon!
I want to create a Supreme Bot. I have already tried clicking the' add to basket' button, but it just doesn't work.
I need some help!
Source code from the Supreme side:
Screenshot from the sourcecode
My code:
driver.findElement(By.xpath("//button[#value='add to basket']")).click();
Thank you for any help!
Try using xpath as :
//input[#value='add to basket']
Use JavascriptExecutor,
WebElement element = driver.findElement(By.xpath("//button[#value='add to basket']"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
You could loop over all buttons and verify the name :
input_fields = webdriver.find_elements_by_tag_name('input')
for field in input_fields:
if field.get_attribute('name') == 'commit'
field.click()
Edit: Mistake, I wrote the answer in python but the logic still holds true for Java, just need to change the syntax.

How to send output to a Text Area In HTML? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am developing a web-based POS,
I have a grid of items which can be purchased.
I want to display the name of the chosen Items
in a text area, as they are being selected.
How can I do that? Java Label? HTML Text Area?
I am a bit lost.
Thank You.
Take a look at this tutorial on Oracle's site. Intially you can set the text value in the constructor but as you add items to your transaction, you can use the append() method to add more lines to the textarea.
You could use a JList which will allow you to add items to a list. It will also allow you to customise the way that the content is rendered as well.
Take a look at How to use Lists

Add image between text in JEditorPane [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
So I know how to insert an image in the JeditorPane in Java. But for example I would like to put the image between (for example) the 3 and 4 line of text in my Jeditorpane.
It's like in Gmail where you can edit your Signature and you can put some images in it..
What I am trying to do is an email service provider and I would also like to make my own Signatures...
What you need is a HTML Editor with live previe:
Ekit seems fairly light (160Ko in one jar, source and jar here)
(source: hexidec.com)
Set content type to text/html and JEditorPane will start rendering the assigned text as HTML. This question explains how to put images. No third party library is necessary, unless you want to use HTML features above 3.2.

Categories