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.
Related
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
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 7 years ago.
Improve this question
I want to display Vo for initial velocity, and it displays fine in MOST places, but on all of my circle buttons, it displays in all caps, so it looks like "VO" instead of "Vo".
Is there a way to fix this? Is it a weird button interaction?
Thanks!
Buttons are all-caps by default since Android 5.0. If you want to disable this, you may have to specify android:textAllCaps="false" on your Buttons.
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 7 years ago.
Improve this question
I have a little question.
I have made a java switch in Netbeans. The switch is attached to a label in my Gui. Whenever i click the Label, i want it to be able to change the image it has.
private void LoopLblMouseReleased(java.awt.event.MouseEvent evt) {
switch(looped)
{
case 0:
looped = 1;
LoopLbl.setIcon("path to image");
break;
case 1:
looped = 0;
break;
};
This the code i have for the switch untill now, but it gives an error when i fill in the path to the image. Can someone help me with this?
but it gives an error when i fill in the path to the image.
LoopLbl.setIcon("path to image");
Did you read the API? The setIcon() takes an Icon as a parameter, not a String.
If you want to know how to use Icons, read the section from the Swing tutorial on How to Use Icons for working examples.
I suggest you keep the tutorial link handy for learning the basics of Swing.
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 8 years ago.
Improve this question
How can I remove border from tab ? Tabs' enable is set to false.
There is a picture for a better idea
Thanks for help.
Possible solution: don't use a JTabbedPane. Instead perhaps you want to use a JList or JLabels, add a MouseListener and on mousePressed swap the view to the right using a CardLayout.
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();