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
public class GmailGoogle {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","E:\\ChromeDriver");
WebDriver wd= new ChromeDriver();
wd.manage().window().maximize();
wd.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1#identifier");
WebElement signin = wd.findElement(By.xpath("//*[#id="Email"]"));
signin.sendKeys("sakthe");
WebElement next = wd.findElement(By.xpath("//*[#id="next"]"));
next.click();
}
}
Left hand side of an operator must be variable while Running in selenium webDriver..Any one can help me to fix this Error
Just make the double quotes in the xpath to single quotes.
//*[#id="Email"] to //*[#id='Email']
//*[#id="next"] to //*[#id='next']
E:\\ChromeDriver to E:/ChromeDriver.exe
Your scrips works fine after this.
Related
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 9 days ago.
Improve this question
My API response gets doubled every time I refresh my page. Is it because my return object is declared outside and every time I refresh it creates a new entry?
#GetMapping(value = "/getPaymentMethodDetails")
public List<AutoPayAccountBean> executePaymentMethodDetails(HttpServletRequest request) {
executeGetPaymentMethodsForUser(request);
if (Objects.nonNull(getPaymentMethodsList())) {
getPaymentMethodsList().stream().forEach(paymentMethod -> {
AutoPayAccountBean accountBean = new AutoPayAccountBean();
accountBean.setPaymentMethod(paymentMethod.getProfileName());
accountBean.setExpirationDate(expirationDate);
accountBean.setHolder(paymentMethod.getHolder());
accountBean.setStatus(paymentMethod.getStatus());
this.paymentMethodResponse.add(accountBean);
});
}
return paymentMethodResponse;
}
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 5 years ago.
Improve this question
I have one question - how to write a cucumber hook that asserts the web URL.
Example -
Let's say I am testing - https://www.usatoday.com/tech/
My Given is as follows -
Given I am on the "/tech/" page
I would like a method to add the base url (www.usatoday.com) + "/tech" and assert whether it is currently on that page
(driver.getURL() ==www.usatoday/tech/)
otherwise navigate to that page if I am not there.
Any Java pros that can help me with this? Many thanks my friends.
#Given("^I am on the \"([^\"]*)\" page$")
public void i_am_on_the_page(String arg) throws throwable{
String newBaseURL = getBaseURL() + arg;
String currentURL = driver.getCurrentURL();
try{
Assert.assertEquals(newBaseURL, currentURL);
}
catch(Exception e){
driver.get(newBaseURL);
}
}
I am assuming that you have a function - getBaseURL() that will provide you the base url.
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 5 years ago.
Improve this question
I have a java selenium program that automatically presses on a button in a website. The code i am using looks like this :
driver.findElement(By.id("button")).click();
I want the program to use if statements if possible.
Thanks for your help.
Use can use findelements by along with if to achieve this. Below code might give you some idea.
if(driver.findElements(by.xpath("//*[#id=253]")).size>0)
{
//element exists with id = 253
// do the stuff
} else
{
//element do not exist with id = 253.
// do the stuff
}
Hope this helps. Thanks.
You may try this:
public void ClickButton () throws InterruptedException
{
WebElement button = driver.findElement(By.id("button"));
String Source = driver.getPageSource();
if (Source.contains(button))
{
button.click();
Thread.sleep(3000);
}
else
{
driver.quit;
}
}
Hope this can be helpful. Let me know if you are still facing problem.
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 5 years ago.
Improve this question
in a block of my java code for an android project I'm trying to get position of a character in a string but application closes unexpectedly.
java code :
public void onClickGet(View v){
String getInput = editText.getText().toString();
if(getInput.contains("(") ) {
//inputEx(getInput);
int a = getInput.indexOf("(");
Toast.makeText(getApplicationContext(),a,Toast.LENGTH_LONG).show();
}
Toast only accept string.. convert it to string first
try{
int a = getInput.indexOf("(");
Toast.makeText(getApplicationContext(),a+"",Toast.LENGTH_LONG).show();
}
catch(Exception e){
e.printStackTrace(); // this will show the error is if error caught
}
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 6 years ago.
Improve this question
The HTML code looks like this:
<font class="snormal">Planning</font>
I need to get the text from onclick. I need pid=DEMO
Can someone help me? I am using java + selenium. Thanks
Find link by text, then get its attribute onclick, then parse it to get pid:
// Initialize driver, navigate to the page
WebDriver driver = new FirefoxDriver(); // or other browser
// ... (navigate to the page, etc.)
// Find the link by partial link text
WebElement link = driver.findElement(By.partialLinkText("Planning"));
// Get the attribute (entire value)
String onclick = link.getAttribute("onclick");
// From here you can use any of the string parsing to get what you want.
// Here's the simple regex way:
String pid = "";
Pattern pattern = Pattern.compile("pid=([^\\&]*)&"); //search for anything between 'pid=' and '&'
Matcher matcher = pattern.matcher(mydata);
if (matcher.find())
{
pid = matcher.group(1); // should be only one
}
System.out.println(pid);
Will print
DEMO