GUI with pyqt5 QLineEdit using Web driver Script

0 votes

I am currently working on a GUI with PyQt5 and attempting to connect it with my selenium web-driver script. I have connected the button to run the script but the problem is script goes into a shopping website and checks out Items for you sizes.I have put in variables inside the script and text boxes inside the GUI.I want to be able to type In the size into the QLineEdit and have the script choose it here is an example of my script.

self.Start_Button_2 = QtWidgets.QPushButton(self.Window_2)

self.Start_Button_2.setGeometry(QtCore.QRect(100, 370, 221, 51))

self.Start_Button_2.setAutoFillBackground(False)

self.Start_Button_2.setObjectName("Start_Button_2")

self.Start_Button_2.clicked.connect(self.BOT)

 

and then I define the bot below:

def BOT(self):

        from selenium import webdriver

        from selenium.webdriver.support.ui import WebDriverWait

        from selenium.webdriver.support import expected_conditions as EC

        from selenium.webdriver.common.by import By

        from selenium.webdriver.support.select import Select

        from selenium.common.exceptions import NoSuchElementException

        import time

 

 

        driver = webdriver.Chrome(executable_path='/Users

        URL = .....

        driver.get(URL)

 

        select = Select(driver.find_element_by_id('s'))

        #select.select_by_visible_text(Size)

 

I have text boxes for size that the user puts in and

    self.Item_Code_2 = QtWidgets.QLineEdit(self.Window_2)

    self.Item_Code_2.setGeometry(QtCore.QRect(20, 40, 125, 21))

    self.Item_Code_2.setObjectName("Item_Code_2")

    self.Name_2 = QtWidgets.QLineEdit(self.Window_2)

I tried size = self.Item_Code_2.text but it is not working. Help me how to connect a text box into a function script?

Jul 23, 2018 in Selenium by Martin
• 4,320 points
1,360 views

1 answer to this question.

0 votes

For a QLineEdit you use the your variable then the self.(the name of it) then .text() So in your case it would be Item_code = (self.Item_Code_2.text()) For combo boxes you would use .currentText() So if you had a combo box for Sizes and stiff it would be Size = (self.Size_2.currentText())

Item_code = (self.Item_Code_2.text())

Size = (self.Size_2.currentText())

answered Jul 23, 2018 by Samarpit
• 5,910 points

Related Questions In Selenium

0 votes
1 answer

Selenium 2.0 web driver Tutorials using .NET

Docs here have an example in C#: http://seleniumhq.org/docs/03_webdriver.html using ...READ MORE

answered Apr 20, 2018 in Selenium by Vardy
• 2,360 points
623 views
0 votes
1 answer

To check that the web page is loaded or not using Selenium Web Driver?

The solution is using Implicit Wait which ...READ MORE

answered May 24, 2018 in Selenium by Meci Matt
• 9,460 points
25,134 views
0 votes
2 answers

Get text using selenium web driver in python

text = driver.find_element_by_class_name("current-text").getText(); ...READ MORE

answered Feb 4, 2019 in Selenium by anonymous
38,100 views
0 votes
1 answer

Popup messages using Selenium Web Driver

Try to get text From Pop Up: String ...READ MORE

answered Jul 18, 2018 in Selenium by Samarpit
• 5,910 points
578 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,649 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,131 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,209 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,865 views
0 votes
2 answers

Python: Using an existing google chrome profile with selenium chrome web driver

The problem is with the string "C:\Users\Eric\Desktop\beeline.txt" Here, \U starts an ...READ MORE

answered May 24, 2019 in Selenium by shinio llahsra
13,124 views
0 votes
1 answer

How to resolve Pycharm Referenced Error with Import Selenium Web driver?

Below will help: Pycharm > Preferences > Project ...READ MORE

answered Jun 26, 2018 in Selenium by Samarpit
• 5,910 points
9,553 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP