Unable to Click on Submit Button

233 views
Skip to first unread message

Vishnu Sai Kode

unread,
Jun 12, 2020, 8:54:16 AM6/12/20
to Selenium Users
Hi Guys,

I have tried with different locators and I didn't find the solution
here is the code i used to click the button 

//Click on Submit Button
//driver.findElement(By.xpath("/html[1]/body[1]/div[1]/div[3]/div[1]/button[1]")).click();
//driver.findElement(By.className("btn btn-primary px-3 py-1 ui-button ui-corner-all ui-widget")).click();
//driver.findElement(By.cssSelector("body:nth-child(2) div.ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-dialog-buttons div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix div.ui-dialog-buttonset > button.btn.btn-primary.px-3.py-1.ui-button.ui-corner-all.ui-widget")).click();                                              
driver.findElement(By.xpath("/html/body/div[1]/div[3]/div/button")).click();

None of these are worked

the element what i got from the browser is:
<button type="button" class="btn btn-primary px-3 py-1 ui-button ui-corner-all ui-widget">Submit</button>






Josh Abrahamsen

unread,
Jun 12, 2020, 1:23:08 PM6/12/20
to seleniu...@googlegroups.com
Try this

*= Will do a contains, in this case contains against the class.
driver.findElement(By.cssSelector("class*=btn-primary").click

Or

Linktext, since Submit is the text of the button.
driver.findElement(By.linktext("Submit").click

Both of those should work.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/89a0cb54-7d43-4cf2-a2bc-1e05b8f08f21o%40googlegroups.com.

Vishnu Sai Kode

unread,
Jun 12, 2020, 1:29:44 PM6/12/20
to seleniu...@googlegroups.com
Hi Josh,

thanks for replying

I tried what you said, but it didn't work



--






Thanks & Regards,
Vishnu Sai.Kode,
0-788916987

Josh Abrahamsen

unread,
Jun 12, 2020, 1:35:07 PM6/12/20
to seleniu...@googlegroups.com
Something else is wrong unrelated to the element then.

sandip vishwakarma

unread,
Jun 12, 2020, 6:08:46 PM6/12/20
to Selenium Users
Hi Vishnu,

Please use this one

driver.findElement(By.xpath("//button[text()='Submit']")).click();

I belive it will work.

Thanks
Sandip


Vishnu Sai Kode

unread,
Jun 13, 2020, 12:55:42 PM6/13/20
to Selenium Users
HI Sandip,

Thanks for replying,

the one you have suggested is not working, 

the error what i'm getting is: Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 24539
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Jun 13, 2020 6:53:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//a[contains(text(),'Account admin')]"}
  (Session info: chrome=83.0.4103.97)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DESKTOP-FAGOPJF', ip: '192.168.0.104', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_221'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 83.0.4103.97, chrome: {chromedriverVersion: 83.0.4103.39 (ccbf011cb2d2b..., userDataDir: C:\Users\User\AppData\Local...}, goog:chromeOptions: {debuggerAddress: localhost:58988}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: 60bff74264e0f9304efb0e33efa0b376
*** Element info: {Using=xpath, value=//a[contains(text(),'Account admin')]}

George Dinwiddie

unread,
Jun 13, 2020, 4:59:30 PM6/13/20
to seleniu...@googlegroups.com
Vishnu,

Is this perhaps somewhere else in your code? It appears it's looking for
'Account admin' instead of 'Submit'.

- George
> --
> You received this message because you are subscribed to the Google
> Groups "Selenium Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to selenium-user...@googlegroups.com
> <mailto:selenium-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/selenium-users/4c4ac011-1503-418d-b2d3-99f32c80238bo%40googlegroups.com
> <https://groups.google.com/d/msgid/selenium-users/4c4ac011-1503-418d-b2d3-99f32c80238bo%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach
----------------------------------------------------------------------

sandip vishwakarma

unread,
Jun 25, 2020, 1:46:36 PM6/25/20
to seleniu...@googlegroups.com
Hi Vishnu,
Hope you got a solution for your problem.if not then please below code which is working for me.


To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0c2070e7-7518-4f75-a446-4ad315f523dc%40iDIAcomputing.com.

sandip vishwakarma

unread,
Jun 25, 2020, 1:49:04 PM6/25/20
to seleniu...@googlegroups.com
Hi Vishnu,
Please previous mail.
Hope you got a solution if not then try below code. it is working for me.

public static void main(String[] args) throws InterruptedException {

System.setProperty("webdriver.gecko.driver", "//E://My space//Selenium//gecko//geckodriver.exe");
//WebDriver driver= new ChromeDriver();
WebDriver driver= new FirefoxDriver();
driver.get("https://test.qualimidev.com/index.php");
Thread.sleep(2000);
driver.findElement(By.xpath("//button[text()='Accept']")).click();
driver.findElement(By.xpath("//input[@name='domain_password']")).sendKeys("ASDdsdsd");
Thread.sleep(2000);
//driver.findElement(By.xpath("//button[text()='Submit']")).submit();
driver.findElement(By.className("ui-dialog-buttonset")).click();



Thanks
Sandip

Vishnu Sai Kode

unread,
Jun 26, 2020, 2:48:27 AM6/26/20
to seleniu...@googlegroups.com
Thank you Sandip,


I tried and it is working fine

Reply all
Reply to author
Forward
0 new messages